Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Share Variable in Script with a Module

by boftx (Deacon)
on Oct 05, 2013 at 00:00 UTC ( [id://1056954]=note: print w/replies, xml ) Need Help??


in reply to Share Variable in Script with a Module

I modified your module slightly as follows:

package my_module; $VERSION = '1.00'; use strict; use Data::Dumper; our $gMessage; sub import { ($gMessage) = @_; print Dumper(\@_); print "Yep, I'm in here ... \n\n"; } &my_sub(); sub my_sub { print "Yep, I'm in here, too ... \n\n"; print $gMessage; } 1;

And this is the resulting output:

$ ./testmymodule.pl Yep, I'm in here, too ... $VAR1 = [ 'my_module', 'xyz' ]; Yep, I'm in here ...

That should clarify why you do not see 'xyz' being printed.

On time, cheap, compliant with final specs. Pick two.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2026-04-16 08:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.