in reply to sorting and comparing hashes
No, the sorting would not work if they were arrays. Read sort again and you'll see why. Not only that, but hashes are by definition sorted by hash, that is, sorted in a manner only meaningful to the interpreter, probably not to you. However, arrays may or may not be sorted. The problem is that the sort function is non-destructive; it won't sort an array in place, but rather return a new array, which is sorted.
Now as for the second problem, I assume you want to print to TEST the contents of playlist, and TEST2 the contents of filelist, with the keys sorted ASCIIbetically. Then you need two for loops:
for (sort keys %playlist) { print TEST "$playlist{$_}\n" } for (sort keys %filelist) { print TEST2 "$filelist{$_}\n" }
Now if you want the values sorted instead, then you need to do:
for (sort values %playlist) { print TEST "$_\n" } for (sort values %filelist) { print TEST2 "$_\n" }
HTH.
|
---|