jshock wrote:
> On May 19, 9:05 pm, [EMAIL PROTECTED] (Randal L. Schwartz) wrote:
> 
>> This seems like it should be an array, not a hash.  Just FYI.
> 
> I used a hash because I wanted to loop through them in sequence. I
> thought I read somewhere that arrays are not automatically sorted.

I think you're getting confused with hashes, which will hand back their key /
value pairs in an unpredictable order. Arrays are ordered lists of scalar
values, and their 'key' is the position of the data item in the list, starting
with zero for the first one.

> I am building a calendar generator as an exercise to help me learn
> perl. When it runs, it asks for the year, then determines if it's a
> leap year, then generates the calendar. It is supposed to write 365
> lines like 2008, JAN 1, TUE. So far it works except I can't seem to
> get it to loop thru and write the weekdays.

If you write

  my @weekdays = qw/ SUN MON TUE WED THU FRI SAT /;

then $weekdays[0] is 'SUN', $weekdays[1] is 'MON' etc.

HTH,

Rob

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to