Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

The hash ref hits!--more--You are confused

by chip (Curate)
on Jul 28, 2000 at 23:09 UTC ( #24977=note: print w/replies, xml ) Need Help??


in reply to RE: RE: A minor epiphany with grep and map
in thread A minor epiphany with grep and map

I'm sorry, Alakaboo, you didn't understand what I wrote at all.

Given the precedence rules, @$x->{y} is not the same as @{$x->{y}}. Rather, it's the same as (@$x)->{y}. Look at the output of -Dx and -Dts if you don't believe me.

In fact, now that I try a simple test, the original code can't work:

$ perl -le '$x={y=>[1]}; print @$x->{y}' Not an ARRAY reference at -e line 1. $ perl -le '$x={y=>[1]}; print @{$x->{y}}' 1

So let's see the full code to the original, OK?

    -- Chip Salzenberg, Free-Floating Agent of Chaos

Replies are listed 'Best First'.
(No, I am an idiot, not confused) Re: The hash ref hits!
by mwp (Hermit) on Jul 28, 2000 at 23:33 UTC

    No, I understood *sigh* I'm just an idiot... I was under the impression that @$x->{y} would work and not die. I guess I gave Perl too much of a benefit of the doubt.

    My apologies Chip, it was good of you to point that out. I hope that *I* didn't come across as being snippy.

    Best regards,

    Mike

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2020-12-01 05:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?