diff options
author | Nicholas Clark <nick@ccl4.org> | 2011-06-06 14:29:19 +0200 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2011-06-11 08:48:14 +0200 |
commit | 0689e260481390ae18db4d1043f84f46f17a2951 (patch) | |
tree | 9efb2c370c2724ceebb2851d4f87a75bae2d3f7e /ext/IPC-Open3 | |
parent | 9f3ee5ee9bc539518437e56340843b97afc63320 (diff) | |
download | perl-0689e260481390ae18db4d1043f84f46f17a2951.tar.gz |
Refactor IPC::Open3::_open3() to find the caller's package itself.
Previously it was passed in as a parameter by IPC::Open2::open2() and
IPC::Open3::open3(), each of which used C<calller> to find it. Move the use of
caller to one place.
It would also be possible to use C<caller> to eliminate the first parameter to
_open3(), but this would add more code than it removes, so doesn't seem wise.
Diffstat (limited to 'ext/IPC-Open3')
-rw-r--r-- | ext/IPC-Open3/lib/IPC/Open3.pm | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/ext/IPC-Open3/lib/IPC/Open3.pm b/ext/IPC-Open3/lib/IPC/Open3.pm index 879b902d8e..916fd84ceb 100644 --- a/ext/IPC-Open3/lib/IPC/Open3.pm +++ b/ext/IPC-Open3/lib/IPC/Open3.pm @@ -199,9 +199,8 @@ use constant DO_SPAWN => $^O eq 'os2' || $^O eq 'MSWin32' || FORCE_DEBUG_SPAWN; sub _open3 { local $Me = shift; - my($package, $dad_wtr, $dad_rdr, $dad_err, @cmd) = @_; + my($dad_wtr, $dad_rdr, $dad_err, @cmd) = @_; my($dup_wtr, $dup_rdr, $dup_err, $kidpid); - if (@cmd > 1 and $cmd[0] eq '-') { croak "Arguments don't make sense when the command is '-'" } @@ -211,8 +210,8 @@ sub _open3 { # tchrist 5-Mar-00 unless (eval { - $dad_wtr = $_[1] = gensym unless defined $dad_wtr && length $dad_wtr; - $dad_rdr = $_[2] = gensym unless defined $dad_rdr && length $dad_rdr; + $dad_wtr = $_[0] = gensym unless defined $dad_wtr && length $dad_wtr; + $dad_rdr = $_[1] = gensym unless defined $dad_rdr && length $dad_rdr; 1; }) { # must strip crud for croak to add back, or looks ugly @@ -227,6 +226,7 @@ sub _open3 { $dup_err = ($dad_err =~ s/^[<>]&//); # force unqualified filehandles into caller's package + my $package = caller 1; $dad_wtr = qualify $dad_wtr, $package unless fh_is_fd($dad_wtr); $dad_rdr = qualify $dad_rdr, $package unless fh_is_fd($dad_rdr); $dad_err = qualify $dad_err, $package unless fh_is_fd($dad_err); @@ -378,7 +378,7 @@ sub open3 { local $" = ', '; croak "open3(@_): not enough arguments"; } - return _open3 'open3', scalar caller, @_ + return _open3 'open3', @_ } sub spawn_with_handles { |