in reply to Hash Question

You want to create a module. You'll probably want to read perlmod first. Here's a very basic example to get you started (untested):

############################ # filename: MyFirstModule.pm package MyFirstModule; our %common_codes_hash = ( '000001' => 'ITEM _First', '000002' => 'Item B', '000003' => 'House', # ....); 1; __END__ ######################## # filename: myscript1.pl use MyFirstModule; my $whatever = $MyFirstModule::common_codes_hash{$foo}; # .... __END__

Later, you can get fancy by using Exporter to export your common data structures or functions into the script's namespace, and other things.

Update: changed the my to our (realized the error at the same time as snowcrash).

--
edan (formerly known as 3dan)

Replies are listed 'Best First'.
Re: Re: Hash Question
by snowcrash (Friar) on Feb 17, 2004 at 15:47 UTC
    > my %common_codes_hash = (....);
    In the module, the file MyFirstModule.pm, %common_codes_hash should be declared with our instead of my. Otherwise it won't work if you put the module and script in two seperate files.
Re: Re: Hash Question
by Taulmarill (Deacon) on Feb 17, 2004 at 15:36 UTC
    itīs a matter of taste, but i whouldnīt store data in modules but in datafiles, textfiles, databases etc.
    modules are for sharing code, not data.
      Except when modules are for sharing data (HTTP::Status, Unicode::CharName , etc)