<br><br><div class="gmail_quote">On Wed, Jun 24, 2009 at 5:35 PM, Ryan Corder <span dir="ltr"><<a href="mailto:ryanc@greengrey.org">ryanc@greengrey.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">On Wed, Jun 24, 2009 at 05:25:08PM -0700, John W. Krahn wrote:<br>
> $ perl -le'<br>
> my $code = <<__CODE__;<br>
> : sub hello {<br>
> : say "Hello World!";<br>
> : }<br>
> __CODE__<br>
><br>
> ( $code = "[code]$code\[/code]" ) =~ s/ +://g;<br>
><br>
> print $code;<br>
> '<br>
> [code] sub hello {<br>
> say "Hello World!";<br>
> }<br>
> [/code]<br>
<br>
</div>>>After I sent my initial email, I had a feeling that your >>answer would be the first one back and that is </blockquote><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
>> entirely my fault. I should have specified that </blockquote><div> >> $code would most likely contain lines<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
>> 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.<br></blockquote><div> </div><br>Er, wouldn't this work even with the added qualification:<br>
<br>$code = "[code]${code}[\\code]"; <br>$code =~ s/^ ://gm; <br> <br>-- <br>Charles DeRykus<br></div><br>