[Israel.pm] use constant and our

Mikhael Goikhman migo at homemail.com
Wed Mar 4 16:19:57 PST 2009


On 05 Mar 2009 00:07:10 +0200, Shmuel Fomberg wrote:
> 
> Today I've seen a weird behavior in a program. I had something like:
> 
> our @list = qw{one two three};
> 
> use constant VAR => {
>     map( { ( $_ => 16 ) } @list ),
> };
> 
> I theorized that it is because "use constant" is set in compile time, 
> and @list is empty in that time. @list is populated in run-time, but 
> that is too late for VAR.

Another alternative to what was suggested already is to be consistent:
   
  use constant LIST => qw(one two three);

  use constant DOUBLE_LIST => LIST, LIST;

Regards,
Mikhael.

-- 
perl -e 'print+chr(64+hex)for+split//,d9b815c07f9b8d1e'



More information about the Perl mailing list