in reply to How can I make a regex apply to each line of a file?
If you just want to print the (modified) contents of the file, you can do
Or if you want to keep the modified file in an array, tryopen (FILE,"<$filename") or die "Cannot open: $!"; map{s/stuff/other_stuff/g;print}(<FILE>);
Update: You could also do this as a one-liner:open (FILE,"<$filename") or die "Cannot open: $!"; @ary = map{s/stuff/other_stuff/g}(<FILE>);
Hope this helps,perl -pe 's/stuff/other_stuff/g' filename.txt
JJ
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re:^2 Oooh, Oooh, Help Me Help Me (:)
by ChemBoy (Priest) on Oct 28, 2001 at 09:11 UTC |