pg has asked for the wisdom of the Perl Monks concerning the following question:
Then, I was thinking that this is not good enough. It will be more nice, if Perl can explicitly warn me. What can I do? so I added "use strict;" at the begining. It worked in the way I expected, my dear Perl complained that I was use strings as ref's.@a = (1,2,3,4); $a = \@a; $a =~ s/ARRAY/HASH/; print $a, "\n"; print $#{keys %{$a}}, "\n"; # print out -1, very nice $b = {"a" => 1, "b" => 2}; $b =~ s/HASH/ARRAY/; print $b, "\n"; print $#{$b}; # print out -1, very nice
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: trick or treat
by Zaxo (Archbishop) on Nov 14, 2002 at 06:41 UTC | |
|
Re: trick or treat
by diotalevi (Canon) on Nov 14, 2002 at 06:38 UTC |