activeperl@listserv.activestate.com
[Top] [All Lists]

Re: Regexp substitution

Subject: Re: Regexp substitution
From: "$Bill Luebkert"
Date: Sat, 15 Jul 2006 18:30:31 -0700
pDale wrote:
> On 7/15/06, John W. Kennedy <jwkenne@xxxxxxxxxxxxx> wrote:
> 
>>But you can do it without using eval:
>>
>>use strict;
>>use warnings;
>>my $p1 = '^([^0-9]*)([0-9].*)$';
>>my $p2 = '"'.'$2 $1'.'"'; #Note wrapping it with double quotes
>>my $str = 'abc123xyz';
>>$str =~ s/$p1/$p2/ee; #Note double e
>>print $str, "\n";
> 
> 
> Yes, that works too!  I like not using eval (it makes me feel "dirty" :) ).

By using /e, aren't you essentially doing an eval on the second operand ?
And twice at that.  I don't see why that would be any more/less preferable.

_______________________________________________
ActivePerl mailing list
ActivePerl@xxxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

<Prev in Thread] Current Thread [Next in Thread>