[ale] perl question: eval'ing variable as s/// pattern match

Chris Woodfield rekoil at semihuman.com
Sat Jan 12 19:30:58 EST 2008


As I emailed Jim privately, right solution, wrong problem :( The goal is 
to make the second version of this code work the same as the first...

s/(pattern)/add stuff to $1/;

currently this returns "add stuff to pattern"

and

$matchtext = '(pattern)';
$replacetext = 'add stuff to $1';
s/$matchtext/$replacetext/;

this returns "add stuff to $1", and doesn't eval the $1 var. Anyone know 
how to make it do this?

-C

On Sat, Jan 12, 2008 at 03:50:18PM -0500, Jim Popovitch wrote:
> On Jan 12, 2008 3:36 PM, Chris Woodfield <rekoil at semihuman.com> wrote:
> > my $match = 'matched $1';
> 
> Try this:
> 
> my $match = 'matched ' . $ARGV[0];
> 
> hth,
> 
> -Jim P.
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale
> 



More information about the Ale mailing list