**** update ****

Ok I figured out what was wrong...I had some old code in another package that was trying to export the wrong functions...and this was causing the errors. If I had just read the error message more carefully I would have saved myself about an hour of time hehe.....

*******************

I am exporting a function from a package. The function in question use a "my" var within the package. Whenever I call the exported function outside of the package I get an error that says the "my" var is not exported so the export failed. Am I doing something wrong here? I am never trying to call the "my" vars outside of the package itself...so no idea why I would be getting this error.

If I remove the export code and fully qualify the function calls then it works fine....

Here are some code snippets:

package BM::Constants::Address; ###################################################################### use strict; use base qw( Exporter ); our @EXPORT_OK = qw( COUNTRIES COUNTRY_NAME COUNTRY_HAS_REGIONS REGION +S REGION_NAME REGION_COUNTRY_ID CITIES CITY_REGION CITY_COUNTRY_ID ); ###################################################################### #look up tables my $country = undef; my $region = undef; my $city = undef; ###################################################################### sub COUNTRIES { my $active = shift; if(! defined $country) { my $db = BM::Database->new(); my $dbh = $db->db_connect(); my $sth = $dbh->prepare(" SELECT country_id, country_name, country_active FROM countries "); $sth->execute; while(my $row = $sth->fetchrow_arrayref) { $country->{$row->[0]} = { name => $row->[1], active => $row->[2], }; } $sth->finish; } if($active) { my %active_country = %$country; foreach my $key(keys %active_country) { delete $active_country{$key} if ! COUNTRY_ACTIVE($key); } return \%active_country; } return $country; } ###################################################################### sub COUNTRY_NAME { my $id = shift; $country = undef if ! exists COUNTRIES->{$id}; return COUNTRIES->{$id}->{name} ? COUNTRIES->{$id}->{name} : q{}; } ###################################################################### sub COUNTRY_ACTIVE { my $id = shift; $country = undef if ! exists COUNTRIES->{$id}; return COUNTRIES->{$id}->{active}; } ###################################################################### #rest of the functions were snipped...

Thanks for the help :-)


In reply to Exporting Issue by BarMeister

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.