Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Regex Substitution in sub

by Aristotle (Chancellor)
on Jun 04, 2003 at 23:31 UTC ( [id://263180]=note: print w/replies, xml ) Need Help??


in reply to Regex Substitution in sub

Just wanted to note that you shouldn't use /o. it does nothing in the examples you showed, so I suspect you don't know what exactly its effects are; in that case it can get you in big trouble. If you are using it because you read that it is about efficiency, read up about the qr// "operator" whose introduction in Perl 5.005 (almost) obsoleted /o.

Makeshifts last the longest.

Replies are listed 'Best First'.
Re: Re: Regex Substitution in sub
by Juerd (Abbot) on Jun 04, 2003 at 23:36 UTC

    I read today in everyone's favourite module:

    $toencode =~ s{&}{&amp;}gso; $toencode =~ s{<}{&lt;}gso; $toencode =~ s{>}{&gt;}gso; $toencode =~ s{"}{&quot;}gso; my $latin = uc $self->{'.charset'} eq 'ISO-8859-1' || uc $self->{'.charset'} eq 'WINDOWS-1252'; if ($latin) { # bug in some browsers $toencode =~ s{'}{&#39;}gso; $toencode =~ s{\x8b}{&#8249;}gso; $toencode =~ s{\x9b}{&#8250;}gso; if (defined $newlinestoo && $newlinestoo) { $toencode =~ s{\012}{&#10;}gso; $toencode =~ s{\015}{&#13;}gso; } } return $toencode;
    This is the heavy strictless module that everyone still recommends. /o? /s? WHY?!

    Can we please stop using and recommending CGI.pm now? Please?

    Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

      Quoting myself from Re^3: Handy dandy CPAN pollution:
      I've poured over CGI myself. Basically, that module is a horrible mess. That's ok for someone who wants to use it, as it's not only one of the few messes that work, but one of the even fewer than work well in practice.
      I don't really like the module, but we need a good replacement. I was switching to CGI::Simple for a while (as I wrote there), but have now actually found CGI's HTML generation useful in combination with Template Toolkit, so I'm reluctantly back to it. We need a full replacement for all of the functionality of that mess before we can stop recommending it.. :-/

      Makeshifts last the longest.

        We need a full replacement for all of the functionality of that mess before we can stop recommending it.. :-/

        CGI stuff (Form parsing, header sending, uploads, etc...)
        CGI::Simple
        Tag generation
        HTML::EasyTags
        Am I forgetting something?

        Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://263180]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-04-25 07:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found