Multiple Sourse files

Discussion in 'Perl Misc' started by makobutm@gmail.com, Sep 20, 2005.

  1. Guest

    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?
    , Sep 20, 2005
    #1
    1. Advertising

  2. Random Task Guest

    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

    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?
    >
    Random Task, Sep 20, 2005
    #2
    1. Advertising

  3. Anno Siegel Guest

    [top posting rectified]

    Random Task <> wrote in comp.lang.perl.misc:
    > 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?


    > 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.
    Anno Siegel, Sep 20, 2005
    #3
  4. 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
    Jürgen Exner, Sep 20, 2005
    #4
  5. Anno Siegel Guest

    Jürgen Exner <> wrote in comp.lang.perl.misc:
    > 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.


    -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.
    Anno Siegel, Sep 27, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JHenstay
    Replies:
    3
    Views:
    539
    osmium
    Jan 11, 2004
  2. Replies:
    4
    Views:
    936
    M.E.Farmer
    Feb 13, 2005
  3. Replies:
    4
    Views:
    328
    Mark Space
    Feb 18, 2008
  4. karthikbalaguru
    Replies:
    3
    Views:
    2,995
    Chris Dollin
    Nov 27, 2008
  5. thufir
    Replies:
    3
    Views:
    203
    Thufir
    Apr 12, 2008
Loading...

Share This Page