What's that die print "..." statement? die already prints the string, no need for a dedicated print.
Your script dies, when P2.pl exists although the message says the contrary.
This code worked fine for me:
#!/usr/bin/perl
#
# p2.pl
#
use strict;
use warnings;
# disable buffering of STDOUT; see the already mentioned "Suffering fr
+om Buffering"
$| = 1;
my $string = "Hello World!";
for ( split //, $string ) {
print $_;
sleep 1;
}
print "\n";
__END__
#! /usr/bin/perl
#
# p1.pl
#
use strict;
use warnings;
my $cmd = '/path/to/p2.pl';
die "(E) '$cmd' does not exist!\n" if !-e $cmd;
print "(I) Executing: $cmd\n";
if ( system( $cmd ) == 0 ) {
print "(I) '$cmd' completed successfully.\n";
}
else {
my $err_msg = "(E) failed to execute: $cmd\n";
warn $err_msg;
killBuild( $err_msg );
exit 1;
}
__END__
My result:
(I) Executing: /tmp/p2.pl
Hello World!
(I) '/tmp/p2.pl' completed successfully.
|