call perl script through another perl script with arguments
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
'require' is like an include. You can't call the 'require'd code as an external program. Its one approach or the other.
You may find these links useful.
Dear Chris,
Thank you for wonderrful links you've provided. I'm going through them. I hope i could find answer somewhere.
Dear David and Chris,
The program has some strange behaviour, that is what i wanted to understand.
See for example
if you put comment near print in add.pl
Code:
use warnings;
my $sum = qx(perl addition.pl 10 -20);
#print "Result is $sum";
it wont result in anything. Even though you've given print in additon.pl
Code:
($a, $b) = @ARGV;
if ( ! defined($a) ) {
print STDERR"usage add <a> <b>\n";
exit;
}
else
{
$n = 0;
$n = $a + $b;
}
print "\nSum of a, b is $n";
but if you remove comments in add.pl, if will result in
Code:
Result is
Sum of a, b is -10
I'm not understaning the program behaviour. Can you please explain me.
All i want is capture the result of addition.pl in $sum, becuase that i would be passing to some other perl script as input.
Thank you very much for your patience in dealing with this issue.
All(!) the output from the 2nd perl script is captured in $sum in the first script.
You're making this overly complex. Why not just put the addition in a subroutine in the first perl script?
Hi chris, the above question is just a part of big coding work, done by my colleague and i'm continuing the work. where i was missing output of some other script captured into a variable. so i wrote this simple program just for my undertanding, as this is my first perl program.
Yet to swim the big sea, i'm just at first tide.... Anyway thanks for your links which are helping me to learn the basic skills.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.