Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Answer: How can I write and call subroutines in separate files?

( #330902=categorized answer: print w/ replies, xml ) Need Help??

Q&A > subroutines > How can I write and call subroutines in separate files? contributed by gridlock

What you can do is write your subroutines in seperate perl (.pl) files. Whenever you need to call them, all you need to do is include them with your code (use the require statement). Each file should end with a true expression, traditionally 1;.

Comment on Answer: How can I write and call subroutines in separate files?
Download Code
Replies are listed 'Best First'.
Re: Answer: How can I write and call subroutines in separate files?
by Anonymous Monk on Feb 23, 2004 at 11:16 UTC
    Hi, dont forget the 1; at the end of the require "file"; where file is:
    #!/usr/bin/perl sub one{ print "one"; } 1;
    otherwise the compiler wont be happy;-)
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (9)
As of 2015-07-29 08:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (261 votes), past polls