in reply to Why does my subroutine not receive the scalar parameter as $_?

In addition, you have trouble brewing once you fix that problem. You are defining your $months hash as a hash reference instead of a hash, and that breaks in the loop that follows. The relevant part of you code (with corrections) is:

my %months = ( ## Change $ to % and { to ( --- no reason t +o use a reference here. 'JAN' => '31', 'FEB' => "$feb", 'MAR' => '31', 'APR' => '30', 'MAY' => '31', 'JUN' => '30', 'JUL' => '31', 'AUG' => '31', 'SEP' => '30', 'OCT' => '31', 'NOV' => '30', 'DEC' => '31', ); ## Changed { to ) my @month_keys = (keys %months); my $tot_days = $dd; for (my $i = 0; $month_keys[$i] ne $mon; $i++) { # Added my

Also, in future, it is better to ask your questions in the Seeker of Perl Wisdom section rather than here in the Q&A section. This is reserved for generic Q&A's, rather than specific questions like your.

Replies are listed 'Best First'.
Re: Answer: Why does my subroutine not receive the scalar parameter as $_?
by belg4mit (Prior) on Aug 26, 2002 at 23:41 UTC
    Actually this is one of the best Q&'A's I've seen. If you think about it, even as an experienced perl person, it's a good question. One could quite reasonably expect this behavior. And of course the answer is...
    local $_ = shift || $_;
    Which I found myself using a bit recently.

    --
    perl -pew "s/\b;([mnst])/'$1/g"