use constant and BEGIN don't mix?

From: J Krugman (jkrugman_at_yahbitoo.com)
Date: 04/30/04


Date: Fri, 30 Apr 2004 18:55:03 +0000 (UTC)


If I try

  my %x;
  BEGIN {
    %x = %{ do '/path/to/some/file' };
  }

...where the file '/path/to/some/file' consists of the string
"+{ A => 1}\n", then everything is fine, but if instead I do

  my %x;
  BEGIN {
    use constant DO_FILE => '/path/to/some/file';
    %x = %{ do DO_FILE };
  }

...I get an error ("Can't use an undefined value as a HASH reference").
(I get this error whether I place the "use constant" statement
inside or before the BEGIN block.)

Is there no way to perform a do operation in a BEGIN block using
a constant? Can someone explain to me, please, what's going on?
(Yes, I did read perlmod; it didn't help me with this one.)

Many thanks!

jill

-- 
To  s&e^n]d  me  m~a}i]l  r%e*m?o\v[e  bit from my a|d)d:r{e:s]s.


Relevant Pages

  • Re: use constant and BEGIN dont mix?
    ... use strict; ... ...I get an error ("Can't use an undefined value as a HASH reference"). ... I did read perlmod; it didn't help me with this one.) ...
    (comp.lang.perl.misc)
  • Re: hash two keys to one index
    ... What goes into the map are pairs of (reference to key, ... When I insert an object into the hash table, I pass in ... void insert(Object obj, int hash) throws HashTableFull ... int probe = 0; ...
    (comp.lang.java.programmer)
  • Re: Net::SFTP::Attributes
    ... when I ask a simple question on the correct usage of a module I would ... If $subref is specified, for each entry in the directory, $subref will ... be called and given a reference to a hash with three keys: ...
    (comp.lang.perl.modules)
  • Re: hash two keys to one index
    ... What goes into the map are pairs of (reference to key, ... When I insert an object into the hash table, I pass in ... void insert(Object obj, int hash) throws HashTableFull ... int probe = 0; ...
    (comp.lang.java.programmer)
  • Re: Hashes of Hashes
    ... group = STRING ... If I swap the order of the declarations, then all of the keys for the ... hash that is referenced by $Data. ... This is known as a "symbolic reference" - using the ...
    (perl.beginners)