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?
[Discipulus]: my father sometimes gives the same result.. good fellow

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2018-02-21 14:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When it is dark outside I am happiest to see ...














    Results (280 votes). Check out past polls.

    Notices?