include files with Perl

D

Dan P

Can you create an include file in perl, filled with subs that require
parameters and then call the appropriate function from the file while
passing in your parameters from your main program. I read
documentation on require and use, but I can't seem to get it working
right.

thanks for your help
 
G

Gunnar Hjalmarsson

Dan said:
Can you create an include file in perl, filled with subs that
require parameters and then call the appropriate function from the
file while passing in your parameters from your main program.

Yes, of course. In Perl 5 such files are normally called modules, and
have the file extension .pm.
I read documentation on require and use, but I can't seem to get it
working right.

What have you tried? Please post some code.

If you are new in this group, it's a good idea to first read the
posting guidelines:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
 
T

Tore Aursand

Can you create an include file in perl, filled with subs that require
parameters and then call the appropriate function from the file while
passing in your parameters from your main program. I read documentation
on require and use, but I can't seem to get it working right.

You want to create modules;

perldoc perlmod
 
D

David Magda

Can you create an include file in perl, filled with subs that
require parameters and then call the appropriate function from the
file while passing in your parameters from your main program. I

I've used do(). So if you have a main.pl and your common sub-routines
are in subs.pl you could do a:

do "subs.pl";
 
B

Brian McCauley

David Magda said:
I've used do(). So if you have a main.pl and your common sub-routines
are in subs.pl you could do a:

do "subs.pl";

Yeah, but it would still be worth investing a few extra minutes to
understand modules.

--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top