You are declaring $corrected within the if block -- After it ends, the variable goes out of scope, making a strict[0] Perl blow up in your face. As you have warnings enabled, it shows that message (which you can look up in perldiag is you don't quite get [1]).
The solution is simple: You just need to widen the scope of $corrected - Which is to say, declare it outside of the if: > my $corrected; if( $year && $month && $day ) { > $corrected = "$year-$monnum{$month}-$day"; > } else { > $corrected = "0000-00-00"; > } > > return $corrected; > Also, if I may, a word about your code: You keep testing some variables for definedness, but don't do anything when they are undefined, so you end up piling on checks. Wouldn't it be simpler to return early? For instance, if $date isn't defined, nothing else is going to work, so why not return there? Brian. [0] http://perldoc.perl.org/strict.html [1] http://perldoc.perl.org/perldiag.html