GreenLantern has asked for the wisdom of the Perl Monks concerning the following question:
Hey folks, pretty experienced program in other languages but I'm crash learning perl for a new job. Following O'Reilly's Llama book. Decided to try something for myself to see if i understand things properly. heres what I have:
#!/usr/bin/perl my %hash = ("fred" => "flintstone", "dino" => undef, "barney" => "rubb +le", "betty" => "rubble"); my @ky = keys %hash; my @vals = values %hash; printf "%10s\t=>%10s\n", "keys", "values"; printf "%10s\t=>%10s\n" x @ky, @ky, @vals;
So what I'm trying to do if you don't know from seeing the above is get output that looks like two columns, first row has "keys => values" the subsequent rows has the keys and values in their respective columns but what I'm getting instead is this:
keys => values barney => betty dino => fred rubble => rubble => flintstone
(but it's of course formatted correctly in neat columns..... web-struggles) can someone tell me where I"m going wrong? I've done something like this but using only a single conversion and an array but now I'm trying to do it with the two conversions and it's not working out for me. Thanks!!!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Need some help with Hashes and formatting
by toolic (Bishop) on Jun 25, 2014 at 01:13 UTC | |
|
Re: Need some help with Hashes and formatting
by Laurent_R (Canon) on Jun 25, 2014 at 06:16 UTC | |
|
Re: Need some help with Hashes and formatting
by farang (Chaplain) on Jun 25, 2014 at 03:01 UTC | |
|
Re: Need some help with Hashes and formatting
by solegaonkar (Beadle) on Jun 25, 2014 at 03:38 UTC | |
by choroba (Cardinal) on Jun 25, 2014 at 11:26 UTC | |
by solegaonkar (Beadle) on Jun 26, 2014 at 09:19 UTC | |
|
Re: Need some help with Hashes and formatting
by LanX (Saint) on Jun 25, 2014 at 13:09 UTC | |
|
Re: Need some help with Hashes and formatting
by GreenLantern (Novice) on Jun 25, 2014 at 15:05 UTC | |
|
Re: Need some help with Hashes and formatting
by Anonymous Monk on Jun 25, 2014 at 18:56 UTC |