Apologies, I was asleep at the wheel during my last response. :-)
The only answer I have is that this is how the designers of Perl decided that the printing of undefined $, @, and % would work. This is probably due to the fact that the undefined value of a scalar *is* different from the undefined value of a hash or an array. Take for instance:
A hash or an array don't have an undefined value. They can either contain something or be empty.
perldoc -f defined [snip] Use of "defined" on aggregates (hashes and arrays) is deprecated. It used to report whether memory for that aggregate has ever been located. This behavior may disappear in future versions of Perl. You should instead use a simple test for size:
perldoc perldata [snip] There are actually two varieties of null strings (sometimes referred to as "empty" strings), a defined one and an undefined one. The defined version is just a string of length zero, such as "". The undefined version is the value that indicates that there is no real value for something, such as when there was an error, or at end of file, or when you refer to an uninitialized variable or element of an array or hash. Although in early versions of Perl, an undefined scalar could become defined when first used in a place expecting a defined value, this no longer happens except for rare cases of autovivification as explained in perlref. You can use the defined() operator to determine whether a scalar value is defined (this has no meaning on arrays or hashes), and the undef() operator to produce an undefined value.
perldoc perltrap [snip] * (Hashes) Hashes get defined before use
local($s,@a,%h); die "scalar \$s defined" if defined($s); die "array [EMAIL PROTECTED] defined" if defined(@a); die "hash \%h defined" if defined(%h);
# perl4 prints: # perl5 dies: hash %h defined
Perl will now generate a warning when it sees defined(@a) and defined(%h).
In scalar context a hash or array will return a numeric value:
$ perl -le'my %x; print scalar %x' 0 $ perl -le'my @x; print scalar @x' 0 $ perl -le'my %x = qw/a b/; print scalar %x' 1/8 $ perl -le'my @x = qw/a b/; print scalar @x' 2
In list context a hash or array (or list) will return their contents.
$ perl -le'my @x = qw/a b/; print @x' ab $ perl -le'my %x = qw/a b/; print %x' ab $ perl -le'print qw/a b/' ab
John -- use Perl; program fulfillment
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>