Very simple - but very stuck. I want to open a file, read it's contents line by line, perform a regex on each line, make a substitution if necessary, write it to the file, then close the file.
#!/usr/bin/perl -w
use strict;
open(FOO, "+< $foo") or die "Can't open $foo: $!";
while (<FOO>) {
chomp;
my $line = $_;
$line = s/hello/goodbye/gi;
}
close FOO;
The regex works, but it doesn't output anything to the file I'm opening. I'm guessing that I need a if statement by the regex and a print statement.....anyone?