in reply to Re: Getting data out of hash
in thread Getting data out of hash
Putting that result in @{} will force it back into a list context
The @{} dereferences the reference to an array regardless of context. Also, if it was list context then shouldn't @{} return the last element of the array in scalar context? Observe:
#!/usr/bin/perl -wl use strict; sub list { return qw(a b c); # real list } my $a_ref = [qw(a b c)]; $, = $"; print "list", @{$a_ref}; print "list", list(); print "scalar " . @{$a_ref}; print "scalar " . list(); __END__ list a b c list a b c scalar 3 scalar c
An arrayref dereferences to an array, not a list. Sure, they're similar but they don't behave the same.
|
|---|