Perl 'system' failure messages

Posted by mmccoo on Stack Overflow See other posts from Stack Overflow or by mmccoo
Published on 2010-05-10T21:58:04Z Indexed on 2010/05/10 22:04 UTC
Read the original article Hit count: 451

Filed under:

Say I have this perl "program" called simple.pl:

#!/usr/bin/perl
use xyz; # xyz is bogus and doesn't exist

And I also have this "program", called simple2.pl:

#!/usr/bin/perl
system("simple.pl");

my $abc = `simple2.pl`;
printf("abc %s\n", $abc);

for both system and backtick, I get this message:

Can't exec "simple.pl": No such file or directory at scripts/perl/simple2.pl line 7.
Can't exec "simple2.pl": No such file or directory at scripts/perl/simple2.pl line 9.

Not very useful for the user calling simple2.pl. Is there a way to get a more useful message?

© Stack Overflow or respective owner

Related posts about perl