Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

package names

by siliconGopher (Initiate)
on Jul 26, 2005 at 09:54 UTC ( [id://478118]=perlquestion: print w/replies, xml ) Need Help??

siliconGopher has asked for the wisdom of the Perl Monks concerning the following question:

monks,
Is it possible to create a package with multiple subroutines, which can be invoked by merely using the subroutine name.
example: Package.pm (contains the foll){ subroutine1 subroutine2 subroutine3 subroutine4 } script.pl(contains){ use Package; use strict; -- etc. ** call to subroutine ** }

Suppose we make a call to a subroutine where shown in the sample code above,

Ideally we would invoke in this fashion,
Package::subroutine1(args)

I am wondering if we can somehow invoke in the following manner
subroutine1(args)

Replies are listed 'Best First'.
Re: package names
by esskar (Deacon) on Jul 26, 2005 at 10:01 UTC
    package Package; use strict; require Exporter; use vars qw/@ISA @EXPORT/; @ISA = qw/Exporter/; @EXPORT = qw/subroutine1 subroutine2 subroutine3 subroutine4/; # ... 1;
      esskar,
      exactly what I was looking for. thank you.
Re: package names
by murugu (Curate) on Jul 26, 2005 at 12:04 UTC

    Hi, Use Exporter module in your package.

    require Exporter; our (@ISA,@EXPORT); @ISA = qw(Exporter); @EXPORT=qw(subroutine1 subroutine2 subroutine3 subroutine4);

    Regards,
    Murugesan Kandasamy

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://478118]
Approved by GrandFather
help
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found