Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: STDOUT qustion

by linuxer (Curate)
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 exists although the message says the contrary.

This code worked fine for me:

#!/usr/bin/perl # # # 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 # # # use strict; use warnings; my $cmd = '/path/to/'; 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/ Hello World! (I) '/tmp/' completed successfully.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2016-10-26 18:42 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (345 votes). Check out past polls.