in reply to unexpected: inside sub($1,$2) if do // then arguments will be changed
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 | |
by Mr. Muskrat (Canon) on Sep 13, 2011 at 18:56 UTC | |
by chromatic (Archbishop) on Sep 13, 2011 at 20:27 UTC | |
by Mr. Muskrat (Canon) on Sep 14, 2011 at 16:00 UTC |