On Wed, 2005-11-30 at 02:16 -0500, Aaron Sherman wrote:
> Ronald J Kimball wrote:
>
> >my @indices = (0) x $maxlen;
> >
> >
> I have no idea why, because it's not more efficent or anything, but I
> always find myself writing:
>
> my @indices = map { 0 } 1..$maxlen;
I believe the latter is quite a bit *less* efficient. It has to
allocate a temporary list containing the numbers from 1 to $maxlen,
whereas the former does not. From perlop:
In the current implementation, no temporary array is created when
the range operator is used as the expression in "foreach" loops
With a small range it probably doesn't matter too much, but I find the
former expression far more self-documenting anyway.much.
-- Jeremy
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm