they both have to do with hashes. question the first: how do/can you sort hashes alphabetically? and, question the second: how do/can you run a loop that loops through two hashes? here's how they come together. some of you may have read
it's been awhile . . ., but if not, you don't really need to. just putting this in unnecessary context :) anyway, at this stage i'm trying to print two hashes so i can look at them and see how they match up. i'd like to sort them before hand so comparing them would be much easier. here's what i've got for the sorting:
sort %filelist;
sort %playlist;
and then for the printing:
for (keys %filelist) {
print TEST $playlist{$_} . "\n";
print TEST2 $filelist{$_} . "\n";
}
now here's the two problems with those snipets. in the first one, it just doesn't sort. or, if it does, hardly the way i want. i need it alphabetically ordered, and when i look at the output, it . . . well . . . isn't. and then for the second part, what happens is that it'll print out filelist, but not playlist. if i say
for (keys %playlist) instead, however, it prints playlist and not filelist. so essentially i need the two hashes sorted and some way of going through the keys for both hashes and printing them out. this is confusing because the sorting would work if they were arrays, would it not? and i just plain have no clue how to go about the second part. thanks in advance
Edit kudra,
2001-10-17
Changed title per ntc suggestion
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.