StormMedic85
Programmer
I can't seem to figure out why the subroutine is only returning the 3 values for the last element in the array I am passing to it in the foreach statement. The array @juliandate contains two elements, so I'd like to perform the calculation for both elements. Can anyone enlighten me as to where I'm going wrong? I am quite a beginner with Perl so try not to laugh too hard at my stupid mistakes and bad formatting. ;0) Thanks for your help!
sub Jul2Greg {
use integer;
my ($a, $g, $dg, $c, $dc, $b, $db, $da, $y);
my ($m, $d, $sgregyear, $sgregmonth, $sgregday, $i);
foreach $i(@juliandate) {
#Other parts of algorithm omitted.
$sgregyear = $y - 4800 + ($m + 2)/12;
$sgregmonth = (($m + 2)%12)+1;
$sgregday = $d + 1;
}
return($sgregmonth, $sgregday, $sgregyear);
}
sub Jul2Greg {
use integer;
my ($a, $g, $dg, $c, $dc, $b, $db, $da, $y);
my ($m, $d, $sgregyear, $sgregmonth, $sgregday, $i);
foreach $i(@juliandate) {
#Other parts of algorithm omitted.
$sgregyear = $y - 4800 + ($m + 2)/12;
$sgregmonth = (($m + 2)%12)+1;
$sgregday = $d + 1;
}
return($sgregmonth, $sgregday, $sgregyear);
}