Cody Pendant has asked for the wisdom of the Perl Monks concerning the following question:
$text = 'Sunt autem quidam e nostris, qui haec subtilius velint tradere et negent satis esse. Quid bonum sit aut quid malum, sensu iudicari. Sed animo etiam ac ratione intellegi posse et voluptatem ipsam per se esse expetendam et dolorem ipsum per se esse fugiendum. '; $text = '<p class="first">' .$text . '</p>'; $text =~ s|(\n\n+)|</p>\1<p class="later">|g; print $text;
And it works just fine.
My next though was "I wonder if I can do both in one statment, and I tried various things, for instance:
but they didn't work.$text = '<p class="first">' . ($text =~ s|(\n\n+)|</p>\1<p class="late +r">|g) . '</p>';
Any ideas? Can it be done in one statement?
--
($_='jjjuuusssttt annootthhrer pppeeerrrlll haaaccckkeer')=~y/a-z//s;print;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Concatenation and Regex on one Statement?
by dws (Chancellor) on Mar 16, 2002 at 01:04 UTC | |
by Cody Pendant (Prior) on Mar 16, 2002 at 01:51 UTC | |
by dws (Chancellor) on Mar 16, 2002 at 02:45 UTC | |
|
Re: Concatenation and Regex on one Statement?
by abstracts (Hermit) on Mar 16, 2002 at 01:57 UTC | |
|
Re: Concatenation and Regex on one Statement?
by trs80 (Priest) on Mar 16, 2002 at 05:20 UTC | |
|
Re: Concatenation and Regex on one Statement?
by Cody Pendant (Prior) on Mar 16, 2002 at 04:10 UTC | |
|
Re: Concatenation and Regex on one Statement?
by gav^ (Curate) on Mar 16, 2002 at 02:38 UTC |