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

Re^3: hash reference doubt

by CountZero (Bishop)
on Jul 20, 2009 at 13:53 UTC ( #781626=note: print w/ replies, xml ) Need Help??


in reply to Re^2: hash reference doubt
in thread hash reference question

but I can't understand what is going when I do %hash->{key}, kindly explain
There is nothing to understand or explain, other than that %hash->{key} should have triggered a syntax error in Perl. Some older Perls didn't and therefore this error was downgraded to a warning to avoid breaking existing scripts.

A reference should always be a scalar (which can be part of an array, a hash or indeed an object or the return value of a subroutine, but not the array, hash, ... itself.

BTW you will trigger a similar warning with the following:

@array = qw /1 2 3 4 5/; print @array->[1];
It really is the same issue.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James


Comment on Re^3: hash reference doubt
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (17)
As of 2014-12-22 13:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (118 votes), past polls