Jul 14, 2000, 7:18 AM
Post #6 of 7
Right on, SixKiller. Globs do not work with any my'd variables.
Had cure written print $cure instead of print $$cure, it would have printed *main::cure because *cure is referring to the glob for any cure variable in the main:: package symbol table (remember that main is the default package). Since any my variable doesn't appear in the symbol table, dereferencing the scalar $cure doesn't yield anything.
The use of "*cure" in cure(*cure) is a trick, kind and gentle folks, into thinking that the *cure really had anything to do the with my $cure and my @cure
It's interesting to note that any name which was globbed in the subroutine call, such as cure(*hello) will print *main::hello (if using print $new), even if $cure and @cure were not changed. It would still print nothing if print $$new were used, because there is no $hello variable in the main:: package defined.
Take out the my for $cure, and it will print "cure", because the cure scalar will be present in the main package table.
Wheeeee... Aren't globs fun?