Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: perl beginner question

by targetsmart (Curate)
on Jun 02, 2009 at 11:22 UTC ( #767559=note: print w/ replies, xml ) Need Help??


in reply to perl beginner question

you have to use use modulename inside your .pl file.
if the .pm file is in the other directory, mention that path in the @INC variable, or use 'use lib' pragma, or -I option to the interpreter.
you can call that routine like classname::routinename as plain
with OO you can call classname->routinename
see my earlier post Re^3: A Class inside a Perl script?


Vivek
-- In accordance with the prarabdha of each, the One whose function it is to ordain makes each to act. What will not happen will never happen, whatever effort one may put forth. And what will happen will not fail to happen, however much one may seek to prevent it. This is certain. The part of wisdom therefore is to stay quiet.


Comment on Re: perl beginner question
Re^2: perl beginner question
by Anonymous Monk on Jun 02, 2009 at 11:38 UTC
    thanks vivek

      Let's say you have a package: test.pm

      package test; sub mysub { return 'babayaga'; } 1;

      Then in your .pl file

      #!/usr/bin/perl use strict; use test; print test::mysub();
      If you want to use directly mysub() read this one here: Exporter

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2014-07-30 11:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (230 votes), past polls