Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: perl beginner question

by targetsmart (Curate)
on Jun 02, 2009 at 11:22 UTC ( [id://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.

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: 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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://767559]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-25 15:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found