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;
In reply to Re: How do I assign & substitute in one statement?
by dimar
in thread How do I assign & substitute in one statement?
by dfaure
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |