Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I am a neophyte perl programmer and I request your wisdom on a problem that perplexs me.
My perl script parses /var/log/maillog and creates a hash using the message id as the key and the to/from as values thusly:
$mailarray{$msgid}{"from"}= $from if ($msgid, $from) = m/.*\[\d+\]: ([a-fA-F0-9]+): from=<(.*)>,/; $mailarray{$msgid}{"to"}= $mailarray{$msgid}{"to"} . " " . $to,/ if ($msgid, $to) = m/.*\[\d+\]: ([a-fA-F0-9]+): to=<(.*)>,/;
I can easily sort onthe $msgid key, but I now need to sort on the $from (or $to) value. The only wisdom I could find is on ordering by the $msgid key.
Can anyone enlighten this novice perl user?
Thank you.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sorting hashes on non-keys
by MarkM (Curate) on Feb 22, 2003 at 16:50 UTC | |
by Anonymous Monk on Feb 22, 2003 at 17:51 UTC | |
|
Re: Sorting hashes on non-keys
by thelenm (Vicar) on Feb 22, 2003 at 16:59 UTC | |
by Anonymous Monk on Feb 22, 2003 at 17:56 UTC | |
by FoxtrotUniform (Prior) on Feb 22, 2003 at 22:11 UTC | |
|
Re: Sorting hashes on non-keys
by hv (Prior) on Feb 22, 2003 at 17:00 UTC | |
|
Re: Sorting hashes on non-keys
by Nkuvu (Priest) on Feb 22, 2003 at 17:02 UTC |