http://qs1969.pair.com?node_id=590033


in reply to Re: Best Perl Practices reviews?
in thread Best Perl Practices reviews?

An excellent recommendation, just keep in mind that EPP is getting a little long in the tooth. It came out in pre-5.005 days so some recommendations are no longer really optimal. An example that comes readily to mind since I just happened to be thumbing through my copy the other day: it recommends avoiding the overhead of /o on dynamically generated regexen by creating an anonymous coderef using string eval and calling that instead.

## not the exact code, but a close facsimile from memory: sub make_matcher { eval qq{sub { \$_[0] =~ /$_[0]/o } } } my $matcher = make_matcher( "dynamic" ); if( $matcher->( "dynamicorama" ) ) { # ... }

Nowadays you can use qr// and get the same performance with less scaffolding (presuming Perl newer than 5.6.1 if I'm recalling correctly from the recent threads here on the topic).

So keep in mind the vintage of the advice. 85%+ of it is probably still germane as is, and the remainder is sound underneath but needs slight tweaks. Of course now I probably should actually get around to swiping a coworker's PBP and reading it this weekend. :)

Replies are listed 'Best First'.
Re^3: Best Perl Practices reviews?
by diotalevi (Canon) on Dec 15, 2006 at 20:52 UTC

    qr// is first available in 5.6.0.

    ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊