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