Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: Re: Re: Using a subroutine as a module

by Anonymous Monk
on Nov 03, 2003 at 10:12 UTC ( #304073=note: print w/replies, xml ) Need Help??

in reply to Re: Re: Using a subroutine as a module
in thread Using a subroutine as a module

Egads, far too many uses of OO are superfluous and/or ill advised already and now you want OO for simple library calls. Just use fully qualified package names:

#### package MyMod; sub foo { "whatever" } 1; ### calling script #!/usr/bin/perl -w use strict; use MyMod; print MyMod::foo();

Replies are listed 'Best First'.
Re: Re: Re: Re: Using a subroutine as a module
by bobn (Chaplain) on Nov 03, 2003 at 15:43 UTC

    Sorry, I disagree. Modularization of code is desirable. IMHO, using a dummy object to acheive this is more valid than fully qualifying the calls for the following reasons:

    • Typically, less typing, as filenames tend to be longer han variable names (in my world, at least)

    • greater flexibility - if you decide to relocate something in the filesystem, you change only your 'use' and 'new' statments, not everyplace the calls are made.

    • "future-proofing" - as the user gains sophisitication, he or she can more easily modify the modules, or create new ones that inherit from the existing. Exporting or fully qualifying can defeat that.

    • "future-proofing" - on the day when the user suddenly wants to set instance data for his routines, he or she is ready.

    Besides, fully qualified calls just look ugly to me, though I suppose it's safer than trusting multiple modules not to stomp on each other or your own functions. Using object methods are also fully qualified.

    --Bob Niederman,

    All code given here is UNTESTED unless otherwise stated.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://304073]
[Corion]: Hey, it's Friday ;))

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (10)
As of 2017-03-24 08:23 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (298 votes). Check out past polls.