bdimych has asked for the wisdom of the Perl Monks concerning the following question:
perlvar says "read-only and dynamically scoped"> perl -v This is perl, v5.10.1 (*) built for i686-cygwin-thread-multi-64int (with 13 registered patches, see perl -V for more detail) Copyright 1987-2009, Larry Wall Perl may be copied only under the terms of either the Artistic License + or the GNU General Public License, which may be found in the Perl 5 source ki +t. Complete documentation for Perl, including FAQ lists, should be found +on this system using "man perl" or "perldoc perl". If you have access to + the Internet, point your browser at http://www.perl.org/, the Perl Home Pa +ge. > cat tmp.pl #!/usr/bin/perl sub mysub { die 'single word expected' if (my $name = shift) !~ /^\w+$/; die 'single word expected' if (my $value = shift) !~ /^\w+$/; } $str = "abc def"; $str =~ /(\w+)\s+(\w+)/; mysub($1, $2); > ./tmp.pl single word expected at ./tmp.pl line 4.
I'm confused a bit$<digits> ($1, $2, ...) Contains the subpattern from the corresponding set of capturing pa +rentheses from the last successful pattern match, not counting patter +ns matched in nested blocks that have been exited already. (Mnemonic: + like \digits.) These variables are all read-only and dynamically sco +ped to the current BLOCK.
have decided to post here
|
---|
Back to
Seekers of Perl Wisdom