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

  • Home
  • SEARCH
  • 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 9129179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:41:12+00:00 2026-06-17T07:41:12+00:00

I like to import symbols from an Exporter powered Perl module using require and

  • 0

I like to import symbols from an Exporter powered Perl module using require and not use. Perl don’t know the variable he just imported.

Perl module sample:

package TheModule;
use strictures;
use base 'Exporter';
use Const::Fast qw( const );
const our $TEST_VAR_1 => 'Test variable 1';
our @EXPORT_OK = qw( $TEST_VAR_1 );
our %EXPORT_TAGS = ( TEST_VAR => [qw( $TEST_VAR_1 )] );

Perl script sample

#!/usr/bin/perl
use strictures;
require TheModule;
TheModule->import( ':TEST_VAR' );
printf "Test variable 1 contains: %s\n", $TEST_VAR_1;

The following example works, but I have to use require instead of use.

#!/usr/bin/perl
use strictures;
use TheModule ( ':TEST_VAR' );
printf "Test variable 1 contains: %s\n", $TEST_VAR_1;

How to import $TEST_VAR_1 within the require environment?

  • 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-17T07:41:13+00:00Added an answer on June 17, 2026 at 7:41 am

    our @EXPORT_TAGS should be our %EXPORT_TAGS. 🙂


    Alright, there is something else wrong. At compile time, when

    printf "Test variable 1 contains: %s\n", $TEST_VAR_1;
    

    is being transformed into ops, $TEST_VAR_1 does not exist in that scope yet, since

    TheModule->import( ':TEST_VAR' );
    

    is executed only at runtime. So, unless you put a BEGIN{} around your require and import, this cannot work.

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

Sidebar

Related Questions

I wrote a program called Hello.py that looks like this: import pygame, sys from
I can use urllib2 to make HEAD requests like so: import urllib2 request =
I build packages from a batch file using commands like: msbuild ..\lib\Package.dproj /target:Build /p:config=%1
i like import c++ dll in my c# application how can i Do this?,
After loading a reference to an assembly with something like: import clr clr.AddRferenceToFileAndPath(r'C:\foo.dll') How
The textbook examples of multiple unpacking assignment are something like: import numpy as NP
I'm trying to profile an instance method, so I've done something like: import cProfile
Having a snippet like this: import yaml class User(object): def __init__(self, name, surname): self.name=
I have a program like this - import weka.core.stemmers.SnowballStemmer; public class TestProject{ public static
I have installed VJET plugin to Eclipse and I'd like to import ExtJs framework

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.