Trying to untaint some variables in Perl, and the following code works great:
if ($year =~ /^(\d{4})$/) {
$year = $1;
} else {
&invalid("year");
}
In the above instance, $1 contains $year if valid. However, when using the ?:
operator, $1 contains "1" when valid:
($year =~ /^(\d{4})$/) ? $year = $1 : &invalid("year");
Anyone see where I might be at fault? I'm confused why this is happening. It's only happening on this machine. Or rather, I have successfully used the ? operator for returning proper match variables for years. I haven't tried this piece of code on any other machine yet.
This is Perl, v5.8.8 built for x86_64-linux-thread-multi