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

Re: calling perl subroutines in other files

by tachyon (Chancellor)
on Sep 26, 2004 at 08:13 UTC ( [id://393898]=note: print w/replies, xml ) Need Help??


in reply to calling perl subroutines in other files

You can do it with use or require. Making your common subroutine code into a library (aka module) is the accepted way. See Simple Module Tutorial for sample code that shows you how. It is really very easy.

cheers

tachyon

  • Comment on Re: calling perl subroutines in other files

Replies are listed 'Best First'.
Re^2: calling perl subroutines in other files
by drock (Beadle) on Sep 27, 2004 at 17:06 UTC
    tachyon, this is great thank you! But I am still trying to understand this. Where do I want to set this up at, in my MAIN program where the file is created or in the subroutine file where the actual work is to be done? Here are some specific questions: how does the calling program ( call the remote files subrouting) know based off your use vars? Is there a mored detailed man page I can read and maybe I will answer my own questions! thanks derek

      The typical construction of a perl widget is to put most/all your subroutines in one or more modules. These modules are your 'subroutine files'. You can save them anywhere. In your script you "use lib '/my/modules/are/here'" to tell Perl where to look for your modueles and then use whichever of your modules you want. Typically the subroutines in one module all relate to one sort of thing. For example DBI is a module for database accesss, Digest::MD5 gives you MD5 hashing.....

      There is plenty of info in the perl docs. See perlman:perlmod perlman:perlmodlib perlman:perlmodinstall perlman:perlnewmod

      cheers

      tachyon

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (2)
As of 2024-04-26 04:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found