From: Perl 5 Porters Date: Wed, 1 May 1996 04:10:28 +0000 (+0000) Subject: Eliminate use of $& to avoid runtime penalty X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6ecfc29d5a0d124e6e6ffb770d1f00e249928746;p=p5sagit%2Fp5-mst-13.2.git Eliminate use of $& to avoid runtime penalty --- diff --git a/lib/open2.pl b/lib/open2.pl index dcd68a8..7d3b970 100644 --- a/lib/open2.pl +++ b/lib/open2.pl @@ -28,8 +28,8 @@ sub main'open2 { # force unqualified filehandles into callers' package local($package) = caller; - $dad_rdr =~ s/^[^']+$/$package'$&/; - $dad_wtr =~ s/^[^']+$/$package'$&/; + $dad_rdr =~ s/^([^']+$)/$package'$1/; + $dad_wtr =~ s/^([^']+$)/$package'$1/; local($kid_rdr) = ++$fh; local($kid_wtr) = ++$fh; diff --git a/lib/open3.pl b/lib/open3.pl index 7c8b6ae..03e151c 100644 --- a/lib/open3.pl +++ b/lib/open3.pl @@ -46,9 +46,9 @@ sub main'open3 { # force unqualified filehandles into callers' package local($package) = caller; - $dad_wtr =~ s/^[^']+$/$package'$&/; - $dad_rdr =~ s/^[^']+$/$package'$&/; - $dad_err =~ s/^[^']+$/$package'$&/; + $dad_wtr =~ s/^([^']+$)/$package'$1/; + $dad_rdr =~ s/^([^']+$)/$package'$1/; + $dad_err =~ s/^([^']+$)/$package'$1/; local($kid_rdr) = ++$fh; local($kid_wtr) = ++$fh;