package MyTools; use strict; BEGIN{ use Exporter (); use vars qw ($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); $VERSION = 0.01; @ISA = qw (Exporter); @EXPORT = qw (); @EXPORT_OK = qw (loadwords); %EXPORT_TAGS = (); } sub loadwords { my @words = qw(a able about above across actually after again all); foreach (@words) { my $some_words{$_} = "1"; } } 1; __END__ #### #!/usr/bin/perl -w use strict; use MyTools qw(loadwords); my %somewords2; # load the words from the module &loadwords; # load the words using the function &loadwords2; print "'all' is one of my words\n" if $some_words{'all'}; print "'all' is one of my words\n" if $somewords2{'all'}; sub loadwords2 { my @words2 = qw(a able about above across actually after again all); foreach (@words2) { $somewords2{$_} = "1"; } } #### syntax error at MyTools.pm line 16, near "$some_words{" Compilation failed in require at ./cosa.pl line 3. BEGIN failed--compilation aborted at ./cosa.pl line 3.