@ncientgoose has asked for the wisdom of the Perl Monks concerning the following question: ⭐ (subroutines)
The problem is I am clearly passing a scalar var to this sub and it is getting a null list. I have tested this thoroughly. Why might it do this? The sub code is in a .pm package, but everything is clearly defined. I have similar subs and calls that work fine!
Here is my call where $form_data{'judeo_date'} is a date like "25-AUG-2002-AD":
Chris
Here is my call where $form_data{'judeo_date'} is a date like "25-AUG-2002-AD":
andmy $j_date = $form_data{'judeo_date'}; my $long_count = get_long_count $j_date if defined $form_data{'judeo_d +ate'};
Thanks,sub get_long_count { my ($dd, $mon, $yyyy, $bc) = split /-/, $_, 4; $yyyy = (0 - $yyyy) if ($bc eq 'BC'); my $feb = 0; if ( int ( $yyyy / 4 ) == ( $yyyy / 4 ) ) { $feb += 29; } else { $feb += 28; } my $months = { 'JAN' => '31', 'FEB' => "$feb", 'MAR' => '31', 'APR' => '30', 'MAY' => '31', 'JUN' => '30', 'JUL' => '31', 'AUG' => '31', 'SEP' => '30', 'OCT' => '31', 'NOV' => '30', 'DEC' => '31', }; my @month_keys = (keys %months); my $tot_days = $dd; for ($i = 0; $month_keys[$i] ne $mon; $i++) { $tot_days += $months{$month_keys[$i]}; } for ($y = $yyyy; $y >= -3114; $y--) { if ( int ( $y / 4 ) == ( $y / 4 ) ) { $tot_days += 366; } else { $tot_days += 365; } } $tot_days -= 223; my $kin = 0; my $uinal = 0; my $tun = 0; my $katun = 0; my $baktun = 0; $baktun = int ( $tot_days / 144000 ) if ( $tot_days >= 144000 ); $tot_days -= ( $baktun * 144000 ); $katun = int ( $tot_days / 7200 ) if ( $tot_days >= 7200 ); $tot_days -= ( $katun * 7200 ); $tun = int ( $tot_days / 360 ) if ( $tot_days >= 360 ); $tot_days -= ( $tun * 360 ); $uinal = int ( $tot_days / 20 ) if ( $tot_days >= 20 ); $tot_days -= ( $uinal * 20 ); $kin = $tot_days; my $long_count; $long_count = "$baktun.$katun.$tun.$uinal.$kin"; }
Chris
P.S. in case your wondering, this sub translates Judeo dates into Mayan long count calendar dates.
Originally posted as a Categorized Question.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Why does my subroutine not receive the scalar parameter as $_?⭐
by rob_au (Abbot) on Aug 25, 2002 at 22:35 UTC | |
Re: Why does my subroutine not receive the scalar parameter as $_?
by BrowserUk (Patriarch) on Aug 25, 2002 at 23:03 UTC | |
by belg4mit (Prior) on Aug 26, 2002 at 23:41 UTC | |
Re: Why does my subroutine not receive the scalar parameter as $_?
by BrowserUk (Patriarch) on Aug 25, 2002 at 22:32 UTC |
Back to
Seekers of Perl Wisdom