v1nsai
February 2nd, 2009, 08:01 PM
Just started trying to teach myself perl, and I'm trying to write a program that will add up the number of letters in each day of the week (monday = 6 tuesday = 7 etc) from keys in a hash, but it just won't compile. Can anyone nudge me in the right direction I've been googling but haven't found what I'm doing wrong yet.
my %month = ( "July" => 31, "August" =>, February => 28 );
for $int ( keys %month{ February } )
{
$day = $int % 7;
if ( $day == 0 ) { $sum += 8; }
if ( $day == 1 ) { $sum += 6; }
if ( $day == 2 ) { $sum += 8; }
if ( $day == 3 ) { $sum += 9; }
if ( $day == 4 ) { $sum += 7; }
if ( $day == 5 ) { $sum += 6; }
}
print "There are $sum letters in the month of February.\n"
my %month = ( "July" => 31, "August" =>, February => 28 );
for $int ( keys %month{ February } )
{
$day = $int % 7;
if ( $day == 0 ) { $sum += 8; }
if ( $day == 1 ) { $sum += 6; }
if ( $day == 2 ) { $sum += 8; }
if ( $day == 3 ) { $sum += 9; }
if ( $day == 4 ) { $sum += 7; }
if ( $day == 5 ) { $sum += 6; }
}
print "There are $sum letters in the month of February.\n"