in reply to unexpected: inside sub($1,$2) if do // then arguments will be changed

(Mnemonic: like \digits)

Try it like this: \(&mysub(<$1> <$2>));

#!/usr/bin/perl -slw use strict; use re 'debug'; sub mysub { die 'single word expected' if (my $name = shift @_) =~ /^\w+$/; die 'single word expected' if (my $value = shift @_) =~ /^\w+$/; } my $str = 'abc def'; $str =~ /(\w+)\s+(\w+)/; print "\(&mysub(<$1> <$2>))";

Replies are listed 'Best First'.
Re^2: unexpected: inside sub($1,$2) if do // then arguments will be changed
by chromatic (Archbishop) on Sep 12, 2011 at 04:49 UTC

      It's a dressed up version of this:

      print "'$1' '$2'";