Here's a horrible possibility using a code assertion:<br><br><br>my $end = 0;<br>my $st = 0<br># no comments to discourage usage <br><br>$code =~ s/ ^(?: \s:(?{$st++;}) | (?{ $end++ if $st }) ) /<br> $st == 1 ? "<code>" : ($end==1 ? "<\\code>" : "")<br>
/gmex; <br><br>which produces:<br><br>foo bar<br>baz<br><br><code> sub hello {<br> say "Hello World!";<br> }<br><\code>asdf<br>snap<br>crackle<br>pop<br><br>--- <br>Charles DeRykus<br>
<br><br><div class="gmail_quote">On Thu, Jun 25, 2009 at 12:00 AM, 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 07:48:22PM -0700, Charles DeRykus wrote:<br>
| Er, wouldn't this work even with the added qualification:<br>
|<br>
| $code = "[code]${code}[\\code]";<br>
| $code =~ s/^ ://gm;<br>
<br>
</div>No, that's the same problem. I can't just wrap the entirety of $code<br>
inside [code] tags. Using your example and if $code contained the following:<br>
<br>
my $code=<<__CODE__;<br>
foo bar<br>
baz<br>
<div class="im"><br>
: sub hello {<br>
: say "Hello World!";<br>
: }<br>
</div>asdf<br>
snap<br>
crackle<br>
pop<br>
__CODE__<br>
<br>
The output would like like this:<br>
<br>
[code]foo bar<br>
baz<br>
<div class="im"><br>
sub hello {<br>
say "Hello World!";<br>
}<br>
</div> asdf<br>
snap crackle<br>
pop<br>
[/code]<br>
<br>
which doesn't work for me. I need to insert the [code] tags on either<br>
side of the substitution, inline with any content that may already be there.<br>
<div><div></div><div class="h5"><br>
<br>
--<br>
Ryan Corder || () ASCII ribbon campaign<br>
<ryanc at <a href="http://greengrey.org" target="_blank">greengrey.org</a>> || /\ against HTML email<br>
<a href="http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x1CB59D69" target="_blank">http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x1CB59D69</a><br>
</div></div></blockquote></div><br>