in reply to create environment variable at run time
Parent (your script):
#!/usr/local/bin/perl use strict; use warnings; $ENV{foo}="bar"; if (fork == 0){ #child exec("./foo.pl"); } else{ print "I'm the parent $ENV{foo}\n"; }
Child (other scripts):
#!/usr/local/bin/perl print "I'm the child $ENV{foo}\n";
This works because environment is propagated to childs (and filehandles and...).
Search for fork+exec for more information.
|
|---|