ceidem has asked for the wisdom of the Perl Monks concerning the following question:
gives this output:#!/usr/bin/perl my %days_in_month = ( "Jan" => 31, "Feb" => 29, "Mar" => 31, "Apr" => 30, "May" => 31, "Jun" => 30, "Jul" => 31, "Aug" => 31, "Sep" => 30, "Oct" => 31, "Nov" => 30, "Dec" => 31 ); foreach $day (%days_in_month) { print "$days_in_month{$day} days hath $day\n"; }
[ceidem@SHARPAM ~/src/perl]$ cal.pl 31 days hath Oct days hath 31 31 days hath Dec days hath 31 31 days hath Mar days hath 31 29 days hath Feb days hath 29 31 days hath Jan days hath 31 30 days hath Nov days hath 30 31 days hath May days hath 31 31 days hath Aug days hath 31 30 days hath Sep days hath 30 31 days hath Jul days hath 31 30 days hath Apr days hath 30 30 days hath Jun days hath 30 [ceidem@SHARPAM ~/src/perl]$
Where does the extraneous "days hath n" come from?
TIA,
- chris
New title per NTC - dvergin 2002-05-01
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: dumb newbie question about hashes and printing from a foreach loop
by Molt (Chaplain) on May 01, 2002 at 15:08 UTC | |
|
Re: dumb newbie question about hashes and printing from a foreach loop
by broquaint (Abbot) on May 01, 2002 at 15:16 UTC | |
|
Re: dumb newbie question about hashes and printing from a foreach loop
by perlplexer (Hermit) on May 01, 2002 at 15:12 UTC | |
|
Re: Printing a hash from a foreach loop
by abaxaba (Hermit) on May 01, 2002 at 18:34 UTC | |
|
Re: Printing a hash from a foreach loop
by ceidem (Initiate) on May 01, 2002 at 20:10 UTC |