SPUG: multi-line substition, all at once.
Ryan Corder
ryanc at greengrey.org
Wed Jun 24 17:35:09 PDT 2009
On Wed, Jun 24, 2009 at 05:25:08PM -0700, John W. Krahn wrote:
> $ perl -le'
> my $code = <<__CODE__;
> : sub hello {
> : say "Hello World!";
> : }
> __CODE__
>
> ( $code = "[code]$code\[/code]" ) =~ s/ +://g;
>
> print $code;
> '
> [code] sub hello {
> say "Hello World!";
> }
> [/code]
After I sent my initial email, I had a feeling that your answer
would be the first one back and that is entirely my fault. I
should have specified that $code would most likely contain lines
of text before and after the lines that begin with ':'. So, I
can't just wrap $code with [code] tags and then do a simple
substitute on it.
Sorry about the lack of clarity in my example.
--
Ryan Corder || () ASCII ribbon campaign
<ryanc at greengrey.org> || /\ against HTML email
http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x1CB59D69
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <http://mail.pm.org/pipermail/spug-list/attachments/20090624/ecad39c3/attachment.bin>
More information about the spug-list
mailing list