Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Using only one subroutine from module file

by ferreira (Chaplain)
on Jun 27, 2007 at 20:01 UTC ( #623726=note: print w/replies, xml ) Need Help??


in reply to Using only one subroutine from module file

First, it is important that you remember the difference between methods (sort of "subs called on an object or class") and subroutines. For methods, you just need to say

require Sheets; Sheets->make_files;
or invoke some kind of constructor (creating an object) and using a piece of code like this:
require Sheets; Sheets->new->make_files;
There is no need for doing more to have access to a method (no need for exporting, etc.)

If the issue is with subroutines, the following may be valid. If you don't want to change Sheets.pm or is not under your control, the following may do the trick you want:

# load Sheets require Sheets; # making it known to the current package # alias the function that matters *make_files = \&Sheets::make_files; # use it make_files() # call cleanly Sheets::make_files
(and you can discard the alias as well and use directly as Sheets::make_files, which is not that bad if used in a limited scope).

The suggestion of the paragraph above "works" independent of the exporter module used or the idiosyncrasies of the provided import function. Well, works if there is not too much magic behind the panes.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2020-10-20 00:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (208 votes). Check out past polls.

    Notices?