Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: Patching a Package (Scalar::Util)

by ikegami (Pope)
on Apr 19, 2006 at 17:26 UTC ( #544415=note: print w/replies, xml ) Need Help??

in reply to Patching a Package (Scalar::Util)

Why is all that stuff in import? That's wrong because it imposes the following two unnecessary restrictions:

  • The module must be loaded using use PatchPackages;. Using require PatchPackages; or use PatchPackages (); will not work, because import does not get executed in those circumstances.

  • use PatchPackages; can only appear once in your code. import is called every time use PatchPackages; is encountered.

Put the code at the top level (as in the following snippet) to fix those problems. It will only be executed once, and it will get executed no matter how the module is loaded.

package PatchPackages; use strict; use version; our $VERSION = qv/0.0.1/; require Scalar::Util; if (! Scalar::Util->can('refaddr')) { ... } 1;

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (3)
As of 2019-05-26 20:16 GMT
Find Nodes?
    Voting Booth?
    Do you enjoy 3D movies?

    Results (153 votes). Check out past polls.

    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!