kirk123 has asked for the wisdom of the Perl Monks concerning the following question:
I use the following code to open a text file and update any strings such as "apple" to orange".
But now I must change any words that that have "apple" as a substring to any words that have "orange" as a substring. For example "data/applered" or "new_apple_dark" becomes " data/orangered" "new_orange_dark" and so on .open (IN,"c:\\data"); @lines = <IN>; close IN; @lines = map { s/\b$old_hostname\b/$new_hostname/sgi; $_ } @lines; open (OUT,">c:\\data") || "can't open data :$! "; print OUT @lines;
How can I alter my substitution to make it work.
--thanks kirk
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: String substitution
by Paladin (Vicar) on Apr 17, 2003 at 19:16 UTC | |
|
Re: String substitution
by thelenm (Vicar) on Apr 17, 2003 at 19:24 UTC | |
by Anonymous Monk on Aug 09, 2006 at 19:59 UTC | |
by ikegami (Patriarch) on Aug 09, 2006 at 20:36 UTC | |
by Anonymous Monk on Aug 11, 2006 at 17:23 UTC | |
|
Re: String substitution
by dpuu (Chaplain) on Apr 17, 2003 at 19:18 UTC |