From: Ilya Zakharevich Date: Fri, 21 Feb 1997 02:07:30 +0000 (-0500) Subject: Avoid $` $& $' in libraries X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2724d5068a405436d3f2cd00aeb8f7b460b24fec;p=p5sagit%2Fp5-mst-13.2.git Avoid $` $& $' in libraries Subject: Pessimal $` $& $' in libraries Corrected: lib/diagnostics.pm lib/Getopt/Long.pm lib/Pod/Text.pm os2/OS2/REXX/REXX.pm $' $` $& eliminated from all the known *.pm. Btw, by this I proudly introduce usage of $+ in standard perl modules ;-). p5p-msgid: <199702210207.VAA03560@monk.mps.ohio-state.edu> --- diff --git a/lib/Getopt/Long.pm b/lib/Getopt/Long.pm index f2b37e9..fa6d5bf 100644 --- a/lib/Getopt/Long.pm +++ b/lib/Getopt/Long.pm @@ -566,7 +566,7 @@ sub GetOptions { my $opt = shift (@optionlist); # Strip leading prefix so people can specify "--foo=i" if they like. - $opt = $' if $opt =~ /^($genprefix)+/; + $opt = $+ if $opt =~ /^($genprefix)+(.*)/s; if ( $opt eq '<>' ) { if ( (defined $userlinkage) @@ -854,19 +854,19 @@ sub GetOptions { sub find_option { - return 0 unless $opt =~ /^$genprefix/; + return 0 unless $opt =~ /^($genprefix)(.*)/s; - $opt = $'; - my ($starter) = $&; + $opt = $+; + my ($starter) = $1; my $optarg = undef; # value supplied with --opt=value my $rest = undef; # remainder from unbundling # If it is a long option, it may include the value. if (($starter eq "--" || $getopt_compat) - && $opt =~ /^([^=]+)=/ ) { + && $opt =~ /^([^=]+)=(.*)/s ) { $opt = $1; - $optarg = $'; + $optarg = $2; print STDERR ("=> option \"", $opt, "\", optarg = \"$optarg\"\n") if $debug; } @@ -992,7 +992,7 @@ sub find_option { # Get key if this is a "name=value" pair for a hash option. $key = undef; if ($hash && defined $arg) { - ($key, $arg) = ($arg =~ /=/o) ? ($`, $') : ($arg, 1); + ($key, $arg) = ($arg =~ /(.*?)=(.*)/s) ? ($1, $2) : ($arg, 1); } #### Check if the argument is valid for this option #### diff --git a/lib/Pod/Text.pm b/lib/Pod/Text.pm index 9d6636a..c62e515 100644 --- a/lib/Pod/Text.pm +++ b/lib/Pod/Text.pm @@ -116,18 +116,18 @@ POD_DIRECTIVE: while () { next; } - if (/^=for\s+(\S+)\s*/s) { + if (/^=for\s+(\S+)\s*(.*)/s) { if ($1 eq "text") { - print STDOUT $',""; + print STDOUT $2,""; } else { # ignore unknown for } next; } - elsif (/^=begin\s+(\S+)\s*/s) { + elsif (/^=begin\s+(\S+)\s*(.*)/s) { $begun = $1; if ($1 eq "text") { - print STDOUT $'.""; + print STDOUT $2.""; } next; } @@ -409,7 +409,7 @@ sub clear_noremap { defined $HTML_Escapes{$3} ? do { $HTML_Escapes{$3} } : do { - warn "Unknown escape: $& in $_"; + warn "Unknown escape: E<$1> in $_"; "E<$1>"; } } diff --git a/lib/diagnostics.pm b/lib/diagnostics.pm index bbae58e..0aa5b54 100644 --- a/lib/diagnostics.pm +++ b/lib/diagnostics.pm @@ -500,7 +500,7 @@ sub unescape { exists $HTML_Escapes{$1} ? do { $HTML_Escapes{$1} } : do { - warn "Unknown escape: $& in $_"; + warn "Unknown escape: E<$1> in $_"; "E<$1>"; } } diff --git a/os2/OS2/REXX/REXX.pm b/os2/OS2/REXX/REXX.pm index 78e0cf9..114e159 100644 --- a/os2/OS2/REXX/REXX.pm +++ b/os2/OS2/REXX/REXX.pm @@ -107,21 +107,21 @@ sub dropall sub TIESCALAR { my ($obj, $name) = @_; - $name =~ s/^[\w!?]+/\U$&\E/; + $name =~ s/^([\w!?]+)/\U$1\E/; return bless \$name, OS2::REXX::_SCALAR; } sub TIEARRAY { my ($obj, $name) = @_; - $name =~ s/^[\w!?]+/\U$&\E/; + $name =~ s/^([\w!?]+)/\U$1\E/; return bless [$name, 0], OS2::REXX::_ARRAY; } sub TIEHASH { my ($obj, $name) = @_; - $name =~ s/^[\w!?]+/\U$&\E/; + $name =~ s/^([\w!?]+)/\U$1\E/; return bless {Stem => $name}, OS2::REXX::_HASH; }