Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Understanding this line of Code

by rafl (Friar)
on Jul 18, 2006 at 13:14 UTC ( #562000=note: print w/ replies, xml ) Need Help??


in reply to Understanding this line of Code

$Aoh{ testa } = @{ exec_select ($sql ) } [0] ->{ home1 };

This piece of code basically does the following

  • Execute exec_select with $sql as its argument (exec_select($sql))
  • Dereference its return value as an array ( @{ ... } )
  • Get the first element of this array ( @{ ... } [0] )
  • Dereference the array element as a hash ( ->{ ... } )
  • Get the key 'home1' from the dereferenced hash ( ->{ home1 } )
  • Assign the value stored in the hash with the key 'home1' to $Aoh{testa}
"Can't use an undefined value as a HASH reference..."

This error is caused by the first element in the above array being undefined. Therefor it can't be dereferenced as a hash.

Cheers, Flo


Comment on Re: Understanding this line of Code
Download Code
Re^2: Understanding this line of Code
by davorg (Chancellor) on Jul 18, 2006 at 13:17 UTC
    This error is caused by the first element in the above array being undefined. Therefor it can't be dereferenced as an array.

    I think you mean "it can't be dereferenced as a hash".

    --
    <http://dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

      Of course. Fixed.

      Thanks, Flo

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2014-07-31 00:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (242 votes), past polls