I am trying to access a file with perl and use substitution on that files contents and print the result of that substitution.
I also need the the file I am accessing to be input on the command line like this: keirnna$ perl_script.pl file.txt
Here is what I have so far:
#!/usr/bin/perl -w
open(INPUT, "+<", "/pretend/path/file.txt")
or die "Couldn't open file..txt for reading: $!\n";
while (<INPUT>) {
$_ =~ s/really/REALLY/gi;
print;
}
close(INPUT);
However all I can get this to do is print the original file and as you can see I am forcing the use of file.txt in the script instead of naming it when I execute the program. I did a lot of searching and reading, but I haven't stumbled upon a solution yet. Sorry if this is a newb question.
I also need the the file I am accessing to be input on the command line like this: keirnna$ perl_script.pl file.txt
Here is what I have so far:
#!/usr/bin/perl -w
open(INPUT, "+<", "/pretend/path/file.txt")
or die "Couldn't open file..txt for reading: $!\n";
while (<INPUT>) {
$_ =~ s/really/REALLY/gi;
print;
}
close(INPUT);
However all I can get this to do is print the original file and as you can see I am forcing the use of file.txt in the script instead of naming it when I execute the program. I did a lot of searching and reading, but I haven't stumbled upon a solution yet. Sorry if this is a newb question.
Comment