For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > September 2005 > Multiple Sourse files









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Multiple Sourse files
makobutm@gmail.com

2005-09-20, 7:01 pm

Hello all,
Is it possible to have multiple sourse files in a perl program like
in PHP? PHP uses "include(script.php)" to run the code in script.php.
But the best way would be like in C where one can run or use a function
in a different sourse file as long as its listed in the header file.
Does perl have a feature like that?

Random Task

2005-09-20, 7:01 pm

Do a google for perl modules ... normally on your system if you have
perl installed ... the are normally named <filename>.pm.

The first line in a perl module is normally "1;" (after the magic cookie
that is).

You can import/use them like any other perlmodule :-)

Hope this helps,
Jim
www.gomba.ca

makobutm@gmail.com wrote:
> Hello all,
> Is it possible to have multiple sourse files in a perl program like
> in PHP? PHP uses "include(script.php)" to run the code in script.php.
> But the best way would be like in C where one can run or use a function
> in a different sourse file as long as its listed in the header file.
> Does perl have a feature like that?
>

Anno Siegel

2005-09-20, 7:01 pm

[top posting rectified]

Random Task <Random@Task.be> wrote in comp.lang.perl.misc:
> makobutm@gmail.com wrote:


[color=darkred]
> Do a google for perl modules ... normally on your system if you have


What good is google going to do? There are far more specific resources
to point to.

> perl installed ... the are normally named <filename>.pm.


That much is true.

> The first line in a perl module is normally "1;"


No, the *last* line of a perl module is usually "1;", but that's a rather
irrelevant technicality. It's certainly not among the first things someone
ought to learn about Perl modules.

> (after the magic cookie that is).


What on earth are you talking about? There are no magic cookies in
Perl modules.

> You can import/use them like any other perlmodule :-)


We were talking about any Perl module. Recursive definitions sometimes
work, recursive explanations never do.

> Hope this helps,


I'm afraid it doesn't.

To the OP: Start with reading perlmod (type "perldoc perlmod" to see it).

Anno
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
Jürgen Exner

2005-09-20, 7:01 pm

makobutm@gmail.com wrote:
> Is it possible to have multiple sourse files in a perl program like
> in PHP? PHP uses "include(script.php)" to run the code in script.php.
> But the best way would be like in C where one can run or use a
> function in a different sourse file as long as its listed in the
> header file. Does perl have a feature like that?


Many different ways, depending upon what you are trying to achive:
perldoc -f do
perldoc -f require
perldoc -f use
perldoc perlmod
I am sure I missed a few.

jue


Jim Gibson

2005-09-20, 7:01 pm

In article <1127228192.688067.19490@g44g2000cwa.googlegroups.com>,
<makobutm@gmail.com> wrote:

> Hello all,
> Is it possible to have multiple sourse files in a perl program like
> in PHP? PHP uses "include(script.php)" to run the code in script.php.
> But the best way would be like in C where one can run or use a function
> in a different sourse file as long as its listed in the header file.
> Does perl have a feature like that?
>


Yes, it does. Look up the Perl keywords 'do', 'require', and 'use' and
read about Perl modules in 'perldoc perlmod'.
Anno Siegel

2005-09-27, 7:56 am

Jürgen Exner <jurgenex@hotmail.com> wrote in comp.lang.perl.misc:
> makobutm@gmail.com wrote:
>
> Many different ways, depending upon what you are trying to achive:
> perldoc -f do
> perldoc -f require
> perldoc -f use
> perldoc perlmod
> I am sure I missed a few.


-P in perlrun.

Anno
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com