Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Hash code bug

by gube (Parson)
on Apr 28, 2006 at 09:06 UTC ( [id://546215]=note: print w/replies, xml ) Need Help??


in reply to Hash code bug

Hi Secode

If you need to get keys as output A B C you just use the below code. Always use Data::Dumper to see the complete stored hash format. I put the print statement in my code just refer that it will show the complete hash format. Your hash format is stored in this format
Your Hash stored format: $VAR1 = { 'A' => { 'B' => {} } };
This output is now stored..so, using this you can get the key output A + B C..so, assign some value for the key if you stored values in hash $VAR1 = { 'A' => { 'B' => { 'C' => 1 } } };
#!/usr/bin/perl use Data::Dumper; my %line; $why = ""; $a = A; $b = B; $c = C; $line{$a}{$b}{$c} = 1; print Dumper(\%line); $i = 1; for $a (keys %line) { for $b (keys %{$line{$a}}) { for $c (keys %{$line{$a}{$b}}) { print "$a $b $c\n"; } } } <p>It prints output : A B C

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2024-04-26 01:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found