Yes, if you fork, both the parent and child should share the signal handler.
The code in your module is unaware of the "global variables" in main. The best thing to do would be to qualify the variable names in the module with the proper namespace. For example:
package Foo;
sub bar {
print $::bar, "\n";
}
package main;
$bar = "Hello, World!";
Foo::bar();
Alternatively you can stomp all over your module's namespace with something like (don't do this)
package Foo;
sub bar {
print $baz, "\n";
}
package main;
$baz = "Hello, World";
foreach my $sym ( keys( %{*{::}} ) ) {
*{"Foo::".$sym} = *{"::".$sym};
}
Foo::bar();
Note how I had to change $bar to $baz in the second example? That's because if I had left it on $bar, I would have stomped on the old coderef in Foo::bar. See why it's a Bad Idea?
Leave the variables in main:: and just call them with a ::
|