Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

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.

Comment on Re: perl beginner question
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 web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2015-10-08 23:42 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (232 votes), past polls