sub num_month{ my $date = shift; ... foreach ...{ my $date = ... # <----this is a new $date scalar, which does not exist outside of this foreach loop } return $date; #<----this is the $date from before the foreach loop -- ie, exactly what was passed to the sub } #### use strict; use warnings; my $test = &GO(1); print $test; sub GO{ my $val = shift; foreach (0..10){ my $val += $_; print $val . "\n"; } return $val; } 0 1 2 3 4 5 6 7 8 9 10 1