Hi all - I can't figure this one out. I have a requirement to grab from some sort of input the elements of a regular expression and execute it. All is fine except when I use $1, $2, ... in the substitution, as:
#!/usr/bin/perl use strict; use warnings; $_ = 'beau cox'; my $match = '(\w+)\s+(\w+)'; my $sub = '$2 $1'; s /$match/$sub/; print "regex: s/$match/$sub/\nresult: $_\n\$1: $1\n\$2: $2\n"; gives the output: regex: s/(\w+)\s+(\w+)/$2 $1/ result: $2 $1 $1: beau $2: cox I know the problem has something to do with my "$2 $1" being inside $sub, but...? Aloha => Beau. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]