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

Re: [FWP] Constants as array refs



Jeff Boes wrote:
> Given:
>   use constant CARRAY => [1, 2, 3, 4];
> 
> What is the syntax to dereference this constant directly into the list of a
> 'foreach' loop?
> 
> None of these work:
> 
>   foreach (@{ CARRAY })

if you run this with -w, you get a hint:

   Ambiguous use of @{CARRAY} resolved to @CARRAY at constant line 3.

so:
 
   foreach (@{ CARRAY() })

works, but i bet someone can come up with a better solution.
--
Steve Lane <sml@zfx.com>

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