thughes has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
Is it possible to override exec globally, from a required package?
does seem to indicate global override is possible, but this test case did not work:
execover.pl:
package execOverride;
BEGIN {
*CORE::GLOBAL::exec = sub {
my $cmd = shift;
print "Called exec override\n";
CORE::exec($cmd);
};
}
1;
main.pl:
require execover.pl
exec(<something to exec>);
It works fine if the override is in the same file as the exec() call.
Short background:
Semantics for invoking a DCL shell script changed between original OpenVMS perl and HP's currently distributed perl build. Old requires "$@file.com", new requires "@file.com". I have a number of programs that have to work under both perls, and was hoping to make the necessary adjustments to the calls in an exec overload.
It would be painful to add the overload manually to each program needing it (and its something that may be forgotten).
- Tracy
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Overriding exec globally
by almut (Canon) on Mar 22, 2010 at 21:05 UTC | |
|
Re: Overriding exec globally
by Anonymous Monk on Mar 23, 2011 at 20:06 UTC | |
|
Re: Overriding exec globally
by delson (Initiate) on Mar 23, 2011 at 20:10 UTC |