Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

accessing subroutines of a module

by ghosh123 (Monk)
on Apr 19, 2014 at 03:20 UTC ( #1082851=perlquestion: print w/replies, xml ) Need Help??

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

Hi
is it possible to access sub routines of a module without using Exporter and creating object ?

Replies are listed 'Best First'.
Re: accessing subroutines of a module
by vinoth.ree (Monsignor) on Apr 19, 2014 at 05:21 UTC

    You can explicitly refer to variables and functions within a package using the :: package qualifier.

    Ex,

    Here is the below sample module.

    MyModule.pm package MyModule; use strict; use warnings; sub func1 { your code here... } sub func2 { your code here... } 1;

    Use the above code into you code as,

    use MyModule; use strict; use warnings; MyModule::funct1();

    So here MyModule::funct1() is the package qualifier, to access the function without creating object and exporting function from MyModule namespace into main namespace.


    All is well
Re: accessing subroutines of a module
by Anonymous Monk on Apr 19, 2014 at 03:27 UTC

    is it possible to access sub routines of a module without using Exporter and creating object ?

    yes, of course, just use the full name, see zentara package/module tutorial

     

    Are you copying some interview questions from somewhere?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2022-05-25 03:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (84 votes). Check out past polls.

    Notices?