in reply to How do I assign & substitute in one statement?
You can also use parenthesis to impose 'list context', and then combine that with 'map' to get what you want in a single line. The drawback is you have to shoehorn your string into a list, which is a bit artificial. The benefit is this may be a little bit easier to read and understand what is going on for beginning perl programmers.
$sBegin = "hello world"; ($sEnd) = map{s/hello/goodbye/g;$_;}($sBegin); print $sEnd;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Answer: How do I assign & substitute in one statement?
by Roy Johnson (Monsignor) on Nov 13, 2004 at 03:38 UTC | |
|
Re: Answer: How do I assign & substitute in one statement?
by Roy Johnson (Monsignor) on Nov 13, 2004 at 15:16 UTC | |
|
Re: Answer: How do I assign & substitute in one statement?
by ysth (Canon) on Nov 14, 2004 at 06:45 UTC |