How can I call one Perl script from another?

If you would like to make a call to, or reference, a Perl script from within a different Perl script, you can accomplish this a system(), exec() or the backtick operator to the path for Perl. For example:

Or store output to array:

Author: admin

I like chocolate, gadgets, open source software, photography, traveling and all shades of green colors. I love spending time with fun loving friends and family members. This is my own online journal.

12 thoughts on “How can I call one Perl script from another?”

  1. So maybe an AI Perlmind — an artificial intelligence written in Perl — could rewrite its own code with improvements and enhancements, then call the new version of itself by the methods described in this weblog.

  2. If i’m not mistaken you mean batch file under NT/XP use system command
    system(“c:\path\to\my.cmd”);

  3. use system command.

    ex: calling_script.pl
    /usr/bin/perl -w

    printf(“%s\n”,”this is calling script”);

    system(“/myhome/caller_script.pl”);
    exit;

  4. Hi, I am calling 1.pl from main.pl file.
    using
    #main.pl
    system (“perl 1.pl”);

    In this case it works fine. But when I am doing

    #main.pl
    system (“perl 1.pl”);
    system (“perl 2.pl”);

    then it doesn’t executes “1.pl” properly.
    So I would like to know, is there any constraint for this? Do I need to take any precautions for this?

    Thanks,

  5. actually i want the CVS tool in Perl ,i want write one programthat is Add which are we used in CVS ,so how i could write that program in perl

  6. How can I call a sister perl script inside a perl script using Expect.pm. When the perl expect ends the script exits never executing the other script even though my last line in the script is

    @myarray=/usr/bin/perl /myscript.pl;
    print $myarray;

  7. in one program i am using system command in that i called another program it is in some other drive how can i fix ths problem

  8. Hi,
    I want to write into file by calling another perl/cgi script.
    sample1.cgi

    from sample1.cgi I m trying to call sample2.pl

    sample2.pl

    When I m executing sample2.pl this works fine, This is able to write a word “AVATAR” into file but when I m using sampe1.cgi I doesn’t work as same.

  9. Hey,

    How do I add a target to a Makefile in a certain directory in order to run a ‘Make all’ from a perl script?

    Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *