Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: How do I import a global variable form a package with require?

by haj (Vicar)
on Jul 22, 2021 at 14:30 UTC ( [id://11135298]=note: print w/replies, xml ) Need Help??


in reply to Re: How do I import a global variable form a package with require?
in thread How do I import a global variable form a package with require?

Alternatively, declare the variable for the compiler. The call to import then assigns the value. This prints 7 (with your A.pm):
#! /usr/bin/env perl use strict; use warnings; our $var; use lib '.'; require A; A->import (':all'); print $var . "\n";

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11135298]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (6)
As of 2024-03-28 16:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found