[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]

URI::Escape::uri_escape, regarding lack of qr//



From URI::Escape v3.13:

sub uri_escape
{
    my($text, $patn) = @_;
    return undef unless defined $text;
    if (defined $patn){
        unless (exists  $subst{$patn}) {
            # Because we can't compile the regex we fake it with a cached sub
            $subst{$patn} =
              eval "sub {\$_[0] =~ s/([$patn])/\$escapes{\$1}/g; }";
            Carp::croak("uri_escape: $@") if $@;
        }
        &{$subst{$patn}}($text);

[etc]

Perhaps Gisle would like to take advantage of qr// in the next release of
this module...?  The only "obstacle" is that it can be kinda slowish to
do:

  $re = qr/.../;
  if (s/$re/.../) { ... }

Is there any workaround other than using the cached sub technique?

-- 

  MIDN 4/C PINYAN, USNR, NROTCURPI     http://www.pobox.com/~japhy/
  jeff pinyan: japhy@pobox.com     perl stuff: japhy+perl@pobox.com
  CPAN ID: PINYAN  http://www.perl.com/CPAN/authors/id/P/PI/PINYAN/
  PerlMonth - An Online Perl Magazine     http://www.perlmonth.com/


Follow-Ups from:
Graham Barr <gbarr@pobox.com>

[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]