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:

system("/usr/bin/perl /path/to/ ");

Or store output to array:

@myarray = `/usr/bin/perl`;

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

  3. use system command.

    /usr/bin/perl -w

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


  4. Hi, I am calling from file.
    system (“perl”);

    In this case it works fine. But when I am doing
    system (“perl”);
    system (“perl”);

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


  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 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 /`;
    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.

    print "Content-type: text/html\n\n";
    use CGI;
    use Switch;
    print qq'
    Field Name : 

    from sample1.cgi I m trying to call

    print "Content-type: text/html\n\n";
    use CGI;
    use Switch;
    my $field="AVATAR";
    open NEW_FILE,">/tmp/test.dat";
    print NEW_FILE "$field";
    close NEW_FILE;

    When I m executing 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?


Leave a Reply

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