Re: getting in between dates in a hash

From: Jan Eden (lists_at_janeden.org)
Date: 02/16/04


Date: Mon, 16 Feb 2004 21:56:29 +0100
To: Joseph Alotta <jalotta@earthlink.net>, Perl Lists <beginners@perl.org>


Joseph Alotta wrote:

>Greetings,
>
>I am having some conceptual problems doing what I think is a fairly
>simple perl task. It is probably that my mind is just blank on
>this. Could someone please recommend a strategy for this.
>
>I have a hash of data:
>
>%highest_level = ( 2001-10-14 => 152, 2002-01-15 => 163, 2003-03-13 =>
>210, 2004-08-07 => 307 );
>
>And I am give some dates in between:
>
>@dates = ( 2001-12-30, 2002-03-19);
>
>I need to find what the highest level was on that date, matching
>between known dates. This is the answer:
>
>%level = ( 2001-12-30 => 152, 2002-03-19 => 210);
>
>
You mean like this?

for (@dates) {
    $level{$_} = $highest_level{$_};
}

HTH,

Jan

-- 
A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.