Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^5: Defining global variable in a subroutine

by dave_the_m (Monsignor)
on Feb 22, 2012 at 16:21 UTC ( [id://955561]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Defining global variable in a subroutine
in thread Defining global variable in a subroutine

An 'our' variable (or any normal variable for that matter) is not shared between parent and child after a fork.
our $x = 1; my $f = fork; die $! unless defined $f; if ($f) { # parent sleep 1; print "parent: x=$x\n"; # prints 1 } else { $x = 2; exit; }

Dave.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-03-29 11:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found