in reply to use strict and subroutines

In your first version you're defined $myname as a lexical variable that is constrained to the function &myname, therefore it doesn't exist outside the subroutine. In your second example it's defined as a lexical variable constrained to the whole file (i.e. effectively global).

The best way to do it would be to use the return value from the subroutine which you are currently ignoring, like this:

#!/usr/local/bin/perl -w use strict; print "my name is ", myname(), "\n"; sub myname { $myname = 'bill'; return $myname; }
--
<http://www.dave.org.uk>

"Perl makes the fun jobs fun
and the boring jobs bearable" - me