Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8139137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:43:32+00:00 2026-06-06T11:43:32+00:00

I have a perl problem: importing symbols, depending on the path elements in @INC

  • 0

I have a perl problem: importing symbols, depending on the path elements in @INC and the use statement.

If I put the full path into @INC, the import works. If a part of the path is in the use statement the module to import is executed, but the import has to be done explicitly:

########################################
# @INC has: "D:/plu/lib/"

#------------------------------------------------
# Exporting file is here: "D:/plu/lib/impex/ex.pm"
#
use strict;
use warnings;
package ex;

use Exporter;
our @ISA = 'Exporter';
our @EXPORT = qw( fnQuark );

sub fnQuark { print "functional quark\n"; }

print "Executing module 'ex'\n";
1;

#------------------------------------------------
# Importing file, example 1, is here: "D:/plu/lib/impex/imp.pl"
#
use strict;
use warnings;
package imp;

use impex::ex;

ex->import( @ex::EXPORT );    # removing this line makes fnQuark unavailable!
                              # Why is this necessary, 'ex.pm' being an Exporter?
fnQuark();

#------------------------------------------------
#  Importing file, example 2, is here: "D:/plu/lib/impex/imp2.pl"
#
use strict;
use warnings;
package imp2;

use lib 'D:/plu/lib/impex';
use ex;

fnQuark();                    # works without explicit import
#-------------------------------------------------

What is my mistake?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T11:43:34+00:00Added an answer on June 6, 2026 at 11:43 am

    When you say

    use Foo;
    

    this is equivalent to:

    BEGIN { 
        require 'Foo.pm';
        Foo->import;
    };
    

    You’ve defined the package in your ex.pm to be named ex, so when you use impex::ex, Perl does an implicit impex::ex->import. But there is no package named impex::ex, so you have to manually do the import from ex to get your symbols.

    The correct way to do this is to put your modules under an existing directory in @INC and name the package after the full path-name relative to the @INC directory. So your impex/ex.pm should begin with package impex::ex; and that’s how you should use it.

    If you’re worried about package names being long and unwieldy, have a look at aliased.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: error of importing DBI in Perl I have a problem when I
I have a problem with Perl and Encoding pragma. (I use utf-8 everywhere, in
I have an interesting problem. I wrote the following perl script to recursively loop
I'm having a little problem with nginx and the Perl FCGI module. I have
I have this Perl subroutine that is causing a problem: sub new { my
I have a Perl project were I just had a problem by making a
please help! I'm really going nuts with this problem! I have a CGI perl
I've an annoying ASP.NET problem: I have a Perl script (see below), which gets
I'd like a native way to fix this problem... I have a perl command
Frankly I don't know Perl at all. I have to solve a problem using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.