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

Replies are listed 'Best First'.
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?
[LanX]: choroba IIRC these errors are indicated
[1nickt]: Missing title suppresses the submit button, I think.
[1nickt]: Petroza to answer your question, no, no special permission is needed to post a question.
[LanX]: did you spam before? :)
LanX has to go/
[ambrus]: I hope we didn't mess up the spam filter rules again.
[ambrus]: Our spam filter rules disallow links to certain domains, and some suspicious pharses that have appeared in previous spam advertising cheap online whatevers.
[LanX]: some servers were lagging today, so I suppose the root cause
[LanX]: ambrus no recent patches
[Petroza]: no i haven't posted anything before. It was a more or less long question with a specific issue. I did post a title and the links i added where only part of the element i was searching within the code (so no purpose other than the question itself).

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (10)
As of 2017-10-17 15:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (233 votes). Check out past polls.

    Notices?