[lug] Perl Question..
Jeff Schroeder
jeff at neobox.net
Wed Apr 16 15:57:08 MDT 2003
Joseph asked:
> Not directly linux related, so hopefully I don't get flamed
> but can anyone think of a way to sort this array into a list
> which matches the actual calandar months? Meaning, Jan, Feb,
> March, April ... Dec. I've been racking my brain today to no
> avail:
I'll give what is probably the obvious answer:
Use a "reference" hash where the month name is the key and the value is
the number; e.g.:
my %months = ("January" => 1, "February" => 2, ...);
Then when you're sorting @array you could do a lookup into the hash to
determine what order to print or manipulate your data.
I don't know if that fits into the scheme of your larger script, but...
HTH,
Jeff
More information about the LUG
mailing list