Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^4: Hashs of hash (multiple value) key problem.

by linuxer (Curate)
on Dec 25, 2008 at 15:26 UTC ( [id://732586]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Hashs of hash (multiple value) key problem.
in thread Hashs of hash (multiple value) key problem.

Please check your script for syntax errors:

$ perl -c script.pl syntax error at /tmp/test.pl line 45, near "if" syntax error at /tmp/test.pl line 61, near "}" $

some comments upon your code.

  • whole code: a clear indentation would help reading and debugging the code! perltidy can help with this!
  • line 31: why do you use s/// here? m// should do the job! The replacement of > (at the beginning of the string) is not needed here as you split the string and use the second part. So why do you remove the >?
  • line 42: %positions is a Hash-of-Arrays; why are you trying to dereference it as a Hash-of-Hashes?
  • line 44: what's that single @? Maybe you want to dereference the array reference in $positions{$key}? If so, you still should rename $value to $position!
  • What do you think $value is for, as you don't use it in your for-loop.
  • line 49: why are you still comparing a string length with an array reference?
  • I stopped analyzing the following lines. But it looks like as you are not aware about what you have stored in $positions{$key}

As tilly already mentioned, you should start learning about perl's complex data structures. Recommended documentation:

Update:

  • comment on line 42 added.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-03-29 01:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found