Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Global Variable

by lamp (Chaplain)
on Sep 22, 2008 at 14:39 UTC ( [id://713031]=note: print w/replies, xml ) Need Help??


in reply to Global Variable

The following is the sample code for achieving the above mentioned scenario using require method.
file1.pl
#!/usr/bin/perl -w use strict; use warnings; our $error; $error = 10; print "before $error \n"; require 'file2.pl'; # you can use 'do' also print "after $error \n";
file2.pl
#!/usr/bin/perl -w use strict; our $error = 20;
output
before 10 after 20

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-04-19 20:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found