C
ccc31807
I have three values that may or may not contain values, call them
$grad1, $grad2, and $grad3. The values they may contain are dates,
like this: 04/12.
My current code munges them like this:
my $grad = ""; # if there are no dates
$grad = $grad1 if $grad1 =~ /\d\d/;
$grad = $grad2 if $grad2 =~ /\d\d/;
$grad = $grad3 if $grad3 =~ /\d\d/;
What I might like to do is this:
my @grad = ($grad1, $grad2, $grad3);
my $grad = ??? #either the last value of @grad that matches /\d\d/ or
"" if none does
Maybe it's a mental block, but I can't figure out how to do this.
Ideas?
Thanks, CC.
$grad1, $grad2, and $grad3. The values they may contain are dates,
like this: 04/12.
My current code munges them like this:
my $grad = ""; # if there are no dates
$grad = $grad1 if $grad1 =~ /\d\d/;
$grad = $grad2 if $grad2 =~ /\d\d/;
$grad = $grad3 if $grad3 =~ /\d\d/;
What I might like to do is this:
my @grad = ($grad1, $grad2, $grad3);
my $grad = ??? #either the last value of @grad that matches /\d\d/ or
"" if none does
Maybe it's a mental block, but I can't figure out how to do this.
Ideas?
Thanks, CC.