Thelonius has asked for the wisdom of the Perl Monks concerning the following question:
I also tried the slightly shorter:package Pexitstat; require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw(exitstatus); our $WEXITSTATUS = sub { $_[0] >> 8 }; sub exitstatus { &$WEXITSTATUS($_[0]); } if (eval "use POSIX; 1") { local $! = 0; my $EAGAIN = POSIX::constant("EAGAIN", 0); my $val = POSIX::constant("WEXITSTATUS", 0); if ($! == $EAGAIN) { $WEXITSTATUS = sub { POSIX::constant("WEXITSTATUS", $_[0]) }; } } 1;
package Pexitstat; require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw(exitstatus); sub exitstatus { $_[0] >> 8; } if (eval "use POSIX; 1") { local $! = 0; my $EAGAIN = POSIX::constant("EAGAIN", 0); my $val = POSIX::constant("WEXITSTATUS", 0); if ($! == $EAGAIN) { *exitstatus = sub { POSIX::constant("WEXITSTATUS", $_[0]) }; } } 1;
Is there a better way to accomplish this?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Conditional function replacement
by shotgunefx (Parson) on Apr 16, 2002 at 19:40 UTC | |
by Thelonius (Priest) on Apr 16, 2002 at 20:15 UTC | |
|
Re: Conditional function replacement
by Thelonius (Priest) on Apr 16, 2002 at 19:43 UTC |