in reply to Re: How to access multiple hash variables defined in a module (Exporter)
in thread How to access multiple hash variables defined in a module

I tried both the methods, I am getting able to get only empty hash :(

  • Comment on Re^2: How to access multiple hash variables defined in a module (Exporter)

Replies are listed 'Best First'.
Re^3: How to access multiple hash variables defined in a module (Exporter)
by zwon (Abbot) on Feb 22, 2010 at 12:49 UTC

    Have you tried:

    use strict; use warnings;
    I see require Exporter; line is missed in your example.

    Update: Here's the working code:

    package XYZ; use strict; use warnings; require Exporter; our @ISA = qw(Exporter); our @EXPORT_OK = qw(%Hash1); our ( %Hash1, %Hash2 ); sub populateHashRoutine { %Hash1 = ( a => 1, b => 2, ); %Hash2 = ( c => 3, d => 4, ); } 1;
    use strict; use warnings; use Data::Dumper; use XYZ qw(%Hash1); XYZ::populateHashRoutine; warn Dumper \%Hash1, \%XYZ::Hash2; __END__ $VAR1 = { 'a' => 1, 'b' => 2 }; $VAR2 = { 'c' => 3, 'd' => 4 };
Re^3: How to access multiple hash variables defined in a module (Exporter)
by shmem (Chancellor) on Feb 22, 2010 at 12:33 UTC

    Then it must be empty. Try outputting the hash inside the package.