Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Pragma-like package

by jbert (Priest)
on Aug 21, 2007 at 08:38 UTC ( #634026=note: print w/replies, xml ) Need Help??


in reply to Pragma-like package

import() has been mentioned, but if what you want to do is to selectively pull in only some methods and variables from the package into your namespace, you might want to look at the Exporter module, which provides an import for you which does just that.

This is the way people used to write reusable perl code, prior to the advent of the current OO style. It's not considered fashionable or good style these days, but it certainly does beat having repeated code in multiple scripts.

Replies are listed 'Best First'.
Re^2: Pragma-like package
by dave0 (Friar) on Aug 21, 2007 at 11:18 UTC
    import() has been mentioned, but if what you want to do is to selectively pull in only some methods and variables from the package into your namespace, you might want to look at the Exporter module, which provides an import for you which does just that.
    You might also want to take a look at Sub::Exporter instead. It's a newer, better way of manipulating the symbols exported by a module.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2021-05-13 08:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (134 votes). Check out past polls.

    Notices?