in reply to Re: Oooh, Oooh, Help Me Help Me (:
in thread How can I make a regex apply to each line of a file?
No, please don't use grep that way, unless you actually want to strip lines out of your input if they don't match the substitution pattern. Use map, instead--that's what it's for.
@footerfile = map {s/something/else/} <FILE>;
Note that the first solution proposed using grep wouldn't have the undesired side-effects, but it's still bad coding practice--never use grep or map in void context (obfuscatory and inefficient).
And Kage, please find a better descriptive title for your question next time...
Update: or, of course, you could alter the array in place after reading it in, using
s/nothing/something/ for @footerfile;
Update 2: of course, it would help if I told you the right syntax for map, too...
(thanks, Zaxo! And I wish I had as good an excuse as jj808 for screwing this one up....)@footerfile = map {s/something/else/;$_} <FILE>;
|
|---|