如何在另一个 perl 脚本中调用一个 perl 脚本? [英] How to call one perl script in another perl script?

查看:86
本文介绍了如何在另一个 perl 脚本中调用一个 perl 脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在主脚本中调用一个 perl 脚本并打印输出.我不知道该怎么做.任何输入请.

I want to call one perl script in main script and print the output. I have no idea how to do it. Any inputs please.

abcd.pl 是我的主脚本,并且有几个单独编写的小脚本,我想在主脚本中调用它们并打印输出.

abcd.pl is my main script and have few small script that written separately I want to call them in main script and print the output.

推荐答案

file 1.pl:

print "i'm perl\n"

在文件 2.pl 中:

$t = `perl 1.pl`;
print $t;

并运行文件2.pl

perl 2.pl

输出为:

i'm perl

或使用require:

文件1.pl:

sub test{
        print "i'm perl\n";
}
1;

文件2.pl:

require '1.pl';
test();

输出:

i'm perl

这篇关于如何在另一个 perl 脚本中调用一个 perl 脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆