Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

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?

-- 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.

Replies are listed 'Best First'.
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:

      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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://767559]
and the fire pops...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (6)
As of 2018-01-22 02:57 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (230 votes). Check out past polls.