Hayest has asked for the wisdom of the Perl Monks concerning the following question:
Hello, I'm tasked with taking an input.txt file that contains in various lines, the word 'new'. I need to create an output.txt file that switches all instances of 'new' regardless of case, to 'old'. I've opened my input.txt file, opened my output.txt file, and have a Regex to make the correct switches, but how do I get it to write to my output.txt file? Any help is appreciated!
use strict; use warnings; open(my $in, "<", "input.txt") or die "Cannot open < input.txt: $!"; open(my $out, ">", "output.txt") or die "Cannot open < output.txt: $!"; while(my $line = <$in>) { $line =~ s/new/old/i; }
|
|---|