Closed p5pRT closed 20 years ago
This:
@foo = (1..10); print *foo{SCALAR}\,*foo{ARRAY}\,*foo{HASH};
prints this:
SCALAR(0xac7b4)ARRAY(0xac7c0)
with perl 5.6.0 and 5.004_04.
Nat
This:
@foo = (1..10);
prints this:
SCALAR(0xac7b4)ARRAY(0xac7c0)
The array assignment is a red herring there. Typeglobs always have a scalar part; regardless of whether or not there is an array. Your code\, without the array assignment:
print *foo{SCALAR}\,*foo{ARRAY}\,*foo{HASH};
prints this:
SCALAR(0xac7b4)
My recollection from the last time this came up is that this is an optimization: Larry supposed that scalars would be common\, and so when a glob is allocated the scalar part is allocated at the same time.
On Aug 20\, Nathan Torkington said:
@foo = (1..10); print *foo{SCALAR}\,*foo{ARRAY}\,*foo{HASH};
prints this:
SCALAR(0xac7b4)ARRAY(0xac7c0)
From perlref:
*foo{THING} returns undef if that particular THING hasn't been used yet\, except in the case of scalars. *foo{SCALAR} returns a reference to an anonymous scalar if $foo hasn't been used yet. This might change in a future release.
Migrated from rt.perl.org#3767 (status was 'resolved')
Searchable as RT3767$