in reply to Creating hashes into a module.

replace
# wrong line foreach (@words) { my $some_words{$_} = "1"; }
with
foreach (@words) { $some_words{$_} = "1"; }
Boris

Replies are listed 'Best First'.
Re: Re: Creating hashes into a module.
by vitojph (Acolyte) on Feb 20, 2004 at 11:12 UTC
    Fixed, but it doesn't work as I need :-( How can I access from the script to the hash %some_words created in the module?
    Res publica non dominetur.
      If you like to export all into the callers namespace put
      @EXPORT = qw (loadwords %some_words);
      into your module code. But this is not a good idea. what about returning a reference to the new created %somewords?
      sub loadwords { my @words = qw(a able about above across actually after again all) +; my %some_words; foreach (@words) { $some_words{$_} = "1"; } return \%some_words; }
      Boris

        I like this solution. I think I'm gonna use references to the hash.

        Thank you everybody.

        Res publica non dominetur.