how can i modify a text file by perl -


i want make 'find/change' function.

  1. open original file.
  2. 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

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -