On Tue, Nov 27, 2001 at 09:52:12AM -0800, David Wheeler wrote: > On Tue, 2001-11-27 at 09:10, Rudy Lippan wrote: > > + return $str if $data_type && $no_escape[$data_type]; > > + $str =~ s/(['\\\0])/$esc{$&}/g; > > ^^ ^^ ^^^^^ > > Umm.. Did you want that to be $1 instead of $&? > > No, but now that I think about it, I could probably eliminate the > parentheses: > > + return $str if $data_type && $no_escape[$data_type]; > + $str =~ s/['\\\0]/$esc{$&}/g;
Using $1 would be a better solution, to avoid the performance penalty incurred by using $&, especially within a module. `perldoc perlvar` $& The string matched by the last successful pattern match (not counting any matches hidden within a BLOCK or eval() enclosed by the current BLOCK). (Mnemonic: like & in some editors.) This variable is read-only. The use of this variable anywhere in a program imposes a considerable performance penalty on all regular expression matches. See the BUGS entry elsewhere in this manpage. Ronald