passing hashes form packages

From: Bzzt (stafili_at_hotmail.com)
Date: 07/28/04


To: beginners@perl.org
Date: Wed, 28 Jul 2004 21:16:04 +0300

Hi,
I am trying to pass a hash from a package to my script with the following.
Can anyone tell me why it doesn't work?
the_package.pm-------------------
#!/usr/local/ActivePerl-5.6/bin/perl -w
package the_package;
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(%exp_hash);
use WWW::Mechanize;
use strict;

my %exp_hash;
$exp_hash{val1}=1;
$exp_hash{val2}=2;
$exp_hash{val3}=2;

the_script.pl-------------------------------------
#!/usr/local/ActivePerl-5.6/bin/perl -w
use warnings;
use strict;
use the_package;
my $value;
foreach $value (keys %exp_hash) {
 print $exp_hash{$value};
 }
print $exp_hash{val1};



Relevant Pages

  • Re: get variables from another file
    ... > use strict; ... > The problem is that the main script does not see the recipients from the ... surrounding their declaration, the implicit block is the file itself.. ... package variables instead: ...
    (comp.lang.perl.misc)
  • Re: Sharing variables between modules
    ... use strict; ... use warnings; ... # Note that this must also come *before* the use Foo line. ... package Foo; ...
    (comp.lang.perl.misc)
  • Re: importing - exporting variables between modules
    ... package IDGenerator; ... use strict; ... package deneme; ...
    (perl.beginners)
  • Re: PERL MAP HELP
    ... An explanation of the sematics of... ... map LIST ... the default package main. ... simplest syntax Perl offers and put a nice big red flag "no strict" so ...
    (comp.lang.perl.misc)
  • goto& destroying @_ - Problem finally replicated
    ... the 'import' function of the Core.pm package below for info there. ... some functionality but still result in the core function being called, ... no strict 'refs'; ...
    (comp.lang.perl.misc)