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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.