> 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 kit. 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 Page. > 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.