Greetings all,
I'm having a bit of trouble with a piece of code of mine. It works kinda like this:
I have two programmes, Launcher and Code. There are two modules, LaunchMod.pm and CodeMod.pm. Straightforward, right? Good. So:
Launcher loads Code from a text file, and passes it in a single string variable to LaunchMod.pm, which then does a little:
unless(fork) { eval($code) || die("Doh - $@\n"); }
Inside Code is:
use strict;
use vars qw($me);
use CodeMod;
$me = "Bob";
&CodeMod::MySub;
And inside CodeMod::MySub is a line or two that, very simply (for testing purposes) prints out the contents of $main::me. Only problem is - it doesn't.
The above says that $main::me is undefined. If I
don't use LaunchMod.pm to fork/eval, and instead put that
same fork/eval code inside Launch itself, everything is hunky-dory.
Obviously I'm setting up the namespace wrong, but I'm just not understanding where... Whether it forks inside the main code (Launch) or off in its module, I don't see how that can affect the eval()ed code like this...
Help?
JP,
-- Alexander Widdlemouse undid his bellybutton and his bum dropped off --
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.