Kevin Old wrote: > Hello everyone, > > I'm trying to define a constant hash and have the following: > > use constant STOPWORDS => map { lc $_ , 1 } qw(a about above across adj > after); > > I do not get a hash from this. > > This does work, however: > > my %stopwords = map { lc $_ , 1 } qw(a about above across adj after); > use constant STOPWORDS => \%stopwords; > > I'm wondering what I'm doing wrong in the first definition. >
The second is only "sort of" constant. It creates a constant reference to the hash, however the hash itself should still be editable which is not probably what you wanted. The problem is that constants are defined at compile time rather than run time. You might be able to accomplish both, using a BEGIN { } wrapper around the first. HTH, http://danconia.org > Any help is appreciated! > > Kevin > -- > Kevin Old > [EMAIL PROTECTED] > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>