Imagine you have a function that returns an @ARRAY of values, like localtime or stat. Wouldn't it be nice to be able to access the elements returned by their name? Here's how I do it:
my @datekeys = ("seconds","minutes","hour","mday","month","year","wday +","yday","isdst"); my %localtime; @localtime{@datekeys} = localtime( time ); printf "It now is %s:%s and the %d day of the week\n" ,$localtime{"hour"} ,$localtime{"minutes"} ,$localtime{"wday"} ;
|
---|
Replies are listed 'Best First'. | |
---|---|
RE: Merging two @ARRAYS into a %HASH
by howard40 (Beadle) on Feb 27, 2000 at 08:08 UTC | |
RE: Merging two @ARRAYS into a %HASH
by btrott (Parson) on Feb 25, 2000 at 23:59 UTC | |
RE: Merging two @ARRAYS into a %HASH
by BBQ (Curate) on Apr 22, 2000 at 09:08 UTC | |
by chromatic (Archbishop) on Apr 22, 2000 at 09:30 UTC | |
by btrott (Parson) on Apr 22, 2000 at 10:23 UTC |