Well, your not stuck :)
You do have an error, however.
perldoc -f each says in it's first paragraph:
When called in list context, returns a 2-element list
consisting of the key and value for the nextelement of
a hash, so that you can iterate overit. When called
in scalar context, returns only the key for the next
element in the hash.
This causes an error in your code that means it will only join the first key and value of your hash (you're calling in list context).
One of the many ways you can accomplish what you are trying to (I think) is this:
my $joined;
foreach my $key ( keys( %hash ) ) {
$joined .= "$key = $hash{$key}<br>";
}
This approxomates the functionality that you display above (
key = value<br>key = value<br> etc. all in one string) without the error.
I'm certain some of the other monks will have other suggestions. Anything involving Perl and a question asking if
i'm stuck is too much for some folk around here to resist.
Dug
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.