in reply to Sorting hashes on non-keys
my @sorted_ids = sort {$mailarray{$a}{"from"} cmp $mailarray{$b}{"from +"}} keys %mailarray;
If your list is large, you may want to make this a bit faster with a Schwartzian Transform.
Two minor things I noticed: I think you'll need to get rid of the ,/ after $to on the fourth line to get your code to run. Also, you're always adding a space to the "to" value even if the "to" value was previously empty. Instead, you may want to check to make sure there is already something there before adding a space separator, maybe like this (although it's kind of ugly and I'm not sure whether you need to worry about the value existing but being undefined, or being defined and empty):
$mailarray{$msgid}{"to"} .= (exists $mailarray{$msgid}{"to"} and length $mailarray{$msgid}{"to +"} ? " " : ""). $to if ($msgid, $to) = ... # your regex here
-- Mike
--
just,my${.02}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Sorting hashes on non-keys
by Anonymous Monk on Feb 22, 2003 at 17:56 UTC | |
by FoxtrotUniform (Prior) on Feb 22, 2003 at 22:11 UTC |