NovMonk has asked for the wisdom of the Perl Monks concerning the following question:

Kind Monks,

I've read the chapters on this in Beginning Perl and some of the tutorials on this site, but I'm just not getting it. I need to use an external file as a lookup table. It's a simple hash. No subroutines, just the hash. When I turn Off "use strict;" in my main program, it runs and returns values for me. But not using strict is Bad and Evil and I want to do this right. More importantly, I want to understand why it's right and where I can go to read more until the light does come on. Looking at the examples I can find, they all seem to be Object Oriented, focusing on using subroutines, and much more complex than this simple thing I'm trying to do.

Here's my program:

#! /usr/bin/perl use strict; use warnings; require "/usr/local/include/"; require "/usr/local/include/"; use lookup; open INFILE, "rentroll.txt" or die "Could not open rentroll.txt $!"; open OUTFILE, ">parsed.rnt.txt" or die "could not open parsed.rnt.txt +for write $!"; my $line= q{}; my @Page = (); #my $lastLine = q{Ending Balance:}; #my $new_rec = 0; #my $cnt = 0; #my (@pos_nums, @neg_nums); while ($line = <INFILE>) { chomp $line; push @Page, $line; if ($line =~/^Development:/) { my $devel = substr($line,13); print OUTFILE "Development = $devel\n"; my $check = $devel_table{$devel}; print OUTFILE "check = $check\n"; if ($check =~ "M") { print OUTFILE "Middletown\n"; } elsif ($check =~ "H") { print OUTFILE "Hamilton\n"; } else { print OUTFILE "Community not in lookup table\n"; } } #last if ($line =~ /$lastLine/); }

And my

#!/usr/bin/perl use strict; use warnings; #require Exporter; #our %devel_table; #our @EXPORT = qw(%devel_table); #our @ISA = qw(Exporter); our %devel_table; %devel_table = ("Townhomes West" => "M", #lots more values in here, of course "Winding Creek Family" => "H", "Dayton Lane Gardens" => "H"); 1;

The error I get when I turn strict on in the main program is this:

Variable "%devel_table" is not imported at .// line 29. Global symbol "%devel_table" requires explicit package name at .//sopw line 29. Execution of .// aborted due to compilation errors.

I believe it has something to do with how I'm not exporting the information correctly, but as I said, the only examples I find are for exporting subroutines, not a hash by itself. Having the lines above commented in or out makes no difference to how the program runs, with or without strict.

Thanking you in advance for leading me back to the right path,