Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Best Perl Practices reviews?

by derby (Abbot)
on Dec 15, 2006 at 13:35 UTC ( #590029=note: print w/replies, xml ) Need Help??


in reply to Best Perl Practices reviews?

Note to AM ... come out from under the rock. Although PBP is a good book, sometimes I feel TheDamian jumps through some pretty funky loops to get his point across. For your first foray into best practices (or idiomatic perl), I would suggest Effective Perl Programming - which by the way has a slightly better rating (and from more reviewers) than PBP.

-derby

Replies are listed 'Best First'.
Re^2: Best Perl Practices reviews?
by Fletch (Bishop) on Dec 15, 2006 at 14:01 UTC

    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. :)

      qr// is first available in 5.6.0.

      ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2023-01-31 02:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?