Phoenix.pm: $& discussion

Michael Dearman mdearman at inficad.com
Fri Aug 25 00:55:40 CDT 2000


Doug Miles wrote:
> 
> Michael Dearman wrote:
> >

-snip-

> > I'm probably missing something, but why can't you just do 'length($1)',
> > for $match_length?
> 
> The reason for this is that for this tag:
> 
> <!-- date -->
> 
> length($1) would give me 4 and length($&) would give me 13, which is
> what I'm looking for.  I want to replace the entire tag, not just the
> contents.

I _was_ confused! Guess I didn't know what $& was actually doing. Do now :)

Well, how about this:

$template =~ /(<--\s*(.+?)\s*-->)/g;

$length = length($1);
$tag = $2;

Mike D.



More information about the Phoenix-pm mailing list