Hello almut, I have double-checked the things you mentioned, but they seem to be correct. I repaste the codes I have used. The package is (with its full absolute path):

/home/UTKU/devel/my_script/dir_two/my_package.pm

The content of this package is as follows:
$ cat dir_two/my_package.pm package my_package; require(Exporter); @ISA = qw(Exporter); @EXPORT = qw( %my_hash ); %my_hash = ( 'my_val' => 7 ); print "my_package is called!\n"; 1;

The script that is expected to take this package is following:

UTKU@utkuhome ~/devel/my_script $ cat my_script.pl #!/usr/bin/perl -w use Data::Dumper; use dir_two::my_package qw( %my_hash ); print @INC; print Dumper(\%my_hash);

Now when the script is called, following comes out to stdout:

UTKU@utkuhome ~/devel/my_script $ ./my_script.pl my_package is called! Name "main::my_hash" used only once: possible typo at ./my_script.pl l +ine 10. /usr/lib/perl5/5.8/cygwin/usr/lib/perl5/5.8/usr/lib/perl5/site_perl/5. +8/cygwin/usr/lib/perl5/site_perl/5.8/usr/lib/perl5/site_perl/5.8/cygw +in/usr/lib/perl5/site_perl/5.8/usr/lib/perl5/vendor_perl/5.8/cygwin/u +sr/lib/perl5/vendor_perl/5.8/usr/lib/perl5/vendor_perl/5.8/cygwin/usr +/lib/perl5/vendor_perl/5.8.$VAR1 = {};

Where is my mistake? Update: I have done the thing you recommended, ie. the package name dir_two::my_package;, it works, thanks. I am not allowed to alter the package namespaces. Is there any other way to do it?

In reply to Re^4: access to hashes with same name, from different packages with same name by utku
in thread access to hashes with same name, from different packages with same name by utku

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.