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

Re: Using only one subroutine from module file

by ferreira (Chaplain)
on Jun 27, 2007 at 20:01 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://623726]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-04-19 13:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found