[comp.lang.perl] Perl-Users Digest #714

marc@ATHENA.MIT.EDU (Marc Horowitz) (04/26/91)

|> In the process of learning perl, I have translated an awk script I wrote.
|> I figured there is a better way to do this:

Well, my solution is:

@Calendar{'Jan','Feb','Mar','Apr','May','Jun',
	  'Jul','Aug','Sep','Oct','Nov','Dec'} = ("01".."12");

Explanation: This is one of those cases where @assocarray{...} really
is correct.  The lhs of the assignment creates a slice of the
associative array.  The rhs is the values you want to assign to each
element of the slice.  The .. operator magically gives you the strings
you want to assign (too bad 'Jan'..'Dec' doesn't work, too :-).

Which brings me to an interesting question: Larry, In the man page you
say:

              					In an array
              context, returns an array of values counting (by
              ones) from the left value to the right value.

A little testing leads me to believe that ``counting (by ones)'' means
``applying magic autoincrement.''  If this is indeed the case, please
document it, since it's really neat.  And if it's an accident,
grandfather the bug so it doesn't go away :-)

		Marc