in reply to calling a perl script within a perl script
`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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: calling a perl script within a perl script
by sgifford (Prior) on Nov 27, 2005 at 04:24 UTC | |
Re^2: calling a perl script within a perl script
by Anonymous Monk on Nov 27, 2005 at 03:19 UTC | |
by sk (Curate) on Nov 27, 2005 at 03:52 UTC |
In Section
Seekers of Perl Wisdom