`perl /home/com/begp/test_script.pl` $f || die "Error!";
You need to change that to -
`perl /home/com/begp/test_script.pl $f` || die "Error!"; # Note the $f position before the backtick.
Also, your || die is tricky. If your test_script.pl returns a zero then it will die. backticks return something so use it. Also consider using system and check for the return on the system call.
An example of the return problem -
[sk] % cat prifile #!/usr/bin/perl -w print @ARGV; # print whatever is sent. [sk] % cat callprifile #!/usr/bin/perl -w my @files = glob ('*'); push (@files, "0"); # adding a zero as the last element in this array +to demonstrate return issue foreach $f (@files) { `prifile $f` || die "something went wrong with $f\n"; } [sk] % callprifile something went wrong with 0
In reply to Re: calling a perl script within a perl script
by sk
in thread calling a perl script within a perl script
by sbp
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |