# 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:

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. Mentifex says:

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. Sarat Chandra says:

How do i call a “.cmd” from a perl script

If i’m not mistaken you mean batch file under NT/XP use system command
system(Ã¢â‚¬Å“c:\path\to\my.cmdÃ¢â‚¬Â);

4. Seetaram Srungaram says:

use system command.

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

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

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

5. Nilesh says:

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,

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

7. Chris says:

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;

8. Amit gupta says:

how do i run perl script in window xp or in dos

9. vijay says:

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

10. Pankaj says:

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.

11. Karen says: