[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Constants as array refs



Said "Jeff Boes" <jboes@qtm.net>:
>>    foreach (@{ CARRAY() })
>> works, but i bet someone can come up with a better solution.
>
>The only other nominee is
>    foreach (@{ +CARRAY })
>
>Dunno which I like better... I've always been attracted to the idea of 'use
>constant', but the syntactical sugar is certainly lacking (IMO).

Is there a reason

  use constant CLIST => 1,2,3,4;

won't work?  That lets you:

  foreach (CLIST) { ... }

as well as

  $x = (CLIST)[2];

-- 
Greg Fast 
Illinois Mathematics and Science Academy
1500 W. Sullivan Rd, Aurora, IL 60506
630.907.5909

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe