Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Global Variable

by lamp (Chaplain)
on Sep 22, 2008 at 14:39 UTC ( #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
Node Status?
node history
Node Type: note [id://713031]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2017-10-17 02:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (218 votes). Check out past polls.

    Notices?