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!!!
In reply to Need some help with Hashes and formatting by GreenLantern
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |