Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: syntax issue

by cjcollier (Novice)
on Dec 28, 2011 at 18:20 UTC ( #945394=note: print w/replies, xml ) Need Help??

in reply to syntax issue

Hi there Sue! I'm not a core dev, so I don't know the why of not being able to use this syntax. We may be able to patch it so you *can* use that syntax, but it would be a bit of a bother, probably. Perl doesn't really have hard and fast rules about differences between types, so a hash could be seen as a list, and can be assigned from one to the other without the need of any type casting macros:
$ cat /tmp/foo my %foo = ('a' => [ 'A','B' ], 'b' => 'B', 'a b' => 'A B' ); my @foo = %foo; my $foo = \@foo; print( "list: [@foo]\n", "listref deref: [@$foo]\n", ); __DATA__ list: [a ARRAY(0x1f12d48) a b A B b B] listref deref: [a ARRAY(0x1f12d48) a b A B b B]
The @{...} around the reference is an explicit de-reference of the value between the { and }. Say you had "@$foo_bar", is this an attempt to de-reference $foo as an arrayref, followed by the string "_bar"? If so, you're doing it wrong, and it should instead be "@{$foo}_bar" Moo, C.J.

Replies are listed 'Best First'.
Re^2: syntax issue
by ikegami (Patriarch) on Dec 28, 2011 at 19:21 UTC
    nit: There's no such thing as a reference to a list in Perl. Your so-called listrefs are array references.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://945394]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2023-12-11 09:10 GMT
Find Nodes?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?

    Results (41 votes). Check out past polls.