in reply to Concatenation and Regex on one Statement?

Any ideas? Can it be done in one statement?

Indeed it can, thanks to the utility of do.

$text = '<p class="first">' . do { $text =~ s|(\n\n+)|</p>\1<p class="later">|g; $text } . '</p>';

Replies are listed 'Best First'.
Re: Re: Concatenation and Regex on one Statement?
by Cody Pendant (Prior) on Mar 16, 2002 at 01:51 UTC
    Interesting.

    What's the difference between "do" and "eval" here?
    --

    ($_='jjjuuusssttt annootthhrer pppeeerrrlll haaaccckkeer')=~y/a-z//s;print;
      What's the difference between "do" and "eval" here?

      Both "do" and "eval" return the value of last expression in the block. "eval" traps exceptions, capturing the argument to "die" and stuffing it into $@. "do" doesn't. I prefer it as a lighter-weight solution to problems like the one you posed.