Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: STDOUT qustion

by linuxer (Deacon)
on Jun 14, 2009 at 11:44 UTC ( #771392=note: print w/ replies, xml ) Need Help??


in reply to STDOUT qustion

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.


Comment on Re: STDOUT qustion
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://771392]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (8)
As of 2014-12-29 10:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (186 votes), past polls