Why doesen't dereferencing work in list context but referencing does?

S

sln

use strict;
use warnings;

my @scalar_array = (0,1,2,3,4,5);

my @refs_array = ();

push @refs_array, $_ for \(@scalar_array);

print $_ for $(@refs_array);

__END__
 
T

Tad J McClellan

my @scalar_array = (0,1,2,3,4,5);
push @refs_array, $_ for \(@scalar_array);
print $_ for $(@refs_array);


You are using the special case for \(@foo), as described in perlref.

There is no corresponding special case for dereferencing.


There is symmetry for the normal (non-special) cases though:

push @refs_array, \$_ for @scalar_array;
...
print $$_ for @refs_array;
 
S

sln

You are using the special case for \(@foo), as described in perlref.

There is no corresponding special case for dereferencing.


There is symmetry for the normal (non-special) cases though:

push @refs_array, \$_ for @scalar_array;
...
print $$_ for @refs_array;

Yes, I know the symetry, thanks!

-sln
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top