how can i modify a text file by perl -
i want make 'find/change' function.
- open original file.
change words through using s/ / / or tr/ / / it's not working, think.
open(txt, ">>text.txt"); $str = <txt>; $str =~ s/'a'/'b'/; print txt $str;
look @ example:
... open rh, "text.txt" or die $!; chomp(my @lines = <rh>); close rh; open wh, ">text.txt" or die $!; foreach $line (@lines) { $line =~ s/'a'/'b'/; print wh "$line\n"; } close wh; ...
Comments
Post a Comment