hiya monks,
I am printing a matrix of numbers out. I am using a hash structure
with one key->array, ie. pushing in like this:
push @{$hash{$id}}, scalar @charcounts;
Problem 1: I want all the numbers to line up when printed out.
The values could be 1, 2 or 3 digit numbers. My script is a CGI, so Im guessing
I want to use printf qq(stuff here) but am not sure.
Problem 2: with one of the keys I must iterate over the multiple values in the
array separatley so I can set each of them as a hyperlink pointing to a different
page.I emptied the multiple values into a new array (dereferencing ?) like this:
@values=@{$hash{$id}};
Then I used a foreach to go through the array. I was surprised to find loads of extra whitespace
appearing. ie. I put into the values:1 2 3 4 5 6 etc. and out came:1(1 blank space)2(2 blank spaces)3(3 blank spaces).
Problem 3:I also have a problem (unless I turn strict off) when I try to print something for which there were
no values pushed in. I was hoping in these situtations just the key would be printed.
Any ideas?
thanks
basm101
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.