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

RE: [FWP] Constants as array refs





> -----Original Message-----
> From: gdf@imsa.edu [mailto:gdf@imsa.edu]
> Sent: Thursday, March 23, 2000 4:18 PM
> To: Jeff Boes
> Cc: fwp@technofile.org
> Subject: Re: [FWP] Constants as array refs
>
> 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];
>

Egg on face. Much gnashing of teeth. I was under the impression from the
limited documentation in 'perldoc constant' that you could only supply array
refs to constant definitions, not lists.

This was reinforced by a bad experience I had when I first started using
constants...

use constant FOO => 1, BAR => 2, OBO => 3;

which didn't do __at all__ what I expected. Anyway, I'm edumacated now, so
I'll slink off, still muttering about constant.pm's cruddy documentation...

----
"To paraphrase Mark Twain, the difference between the right program and
almost the right program is like the difference between lightning and a
lightning bug. The difference is just a bug."
--Danny Hillis, "The Pattern on the Stone" (1998)
___________
Jeff Boes  <><  jboes@qtm.net
Mur Consulting  http://www.qtm.net/~jboes/


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