Hack #73. Know What's Core and When

Keep track of the core modules you're using and not using.

Not every Perl installation is fortunate enough to be able to install the latest released version of the core as soon as it is available or to install the freshest modules off of the CPAN as soon as they hit the index. Some developers on legacy systems have to be very careful to avoid the wrath of their system administrators for whom stability is a way of life, not just a goal.

Though Perl 5's standard library has always provided a lot of features, it has grown over time. What's standard and usable everywhere as of Perl 5.8.7 isn't the same as what existed as of Perl 5.004. How can you know, though, without either digging through release notes or watching your carefully constructed code break when put on the testing machine?

Use Module::CoreList.

The Hack

Suppose you've read perldoc perlport and have resolved never to write unportable, hardcoded file paths anymore. You've browsed the documentation of File::Spec and realize that a few careful calls can make your code more likely to work on platforms as exotic as Windows (or even VMS, but that's scary).

Unfortunately for your good intentions, your development platform is a box that shipped with Perl 5.004 from way back when the network really was the computer. Before replacing all of your join( '/', @path, $filename ) code with calls to shiny catfile( ), your sense of duty and due diligence causes you to ask "Wait, when did File::Spec

Get Perl Hacks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.