in reply to Check for "No child processes" internationally

I don't think that "No child process" is locale sensitive, but on some platforms could produce "No children" instead (citation). However, you can ignore the error message's text by remembering that $! is a dual-valued variable; In string context it returns the error message. In numeric context, it returns the error number, which can be tested against the &Errno::ECHILD constant (Errno).

Or you can use %! in some variant on the example code shown in Errno's POD:

# A variation on Errno's POD example: use Errno qw( ECHILD ); # ........ if ( not close $something ) { if( not $!{ECHILD} ) { die "Houston, we have a problem: $!"; } else { # Silence is golden; ECHILD is silent. } }

Dave

Replies are listed 'Best First'.
Re^2: Check for "No child processes" internationally
by Anonymous Monk on May 09, 2013 at 06:58 UTC

    # A variation on Errno's POD example: use Errno qw( ECHILD );

    :) Unless you need the number/constant, you don't need to import from Errno

    Also, you don't need to actually use Errno;, using %! in your code will load Errno for you

      Thanks for the tips. :)

      The updated code (removed the 'use', and of course the import):

      # A variation on Errno's POD example: # ........ Do your stuff ........ if ( not close $something ) { if( not $!{ECHILD} ) { die "Houston, we have a problem: $!"; } else { # Silence is golden; ECHILD is silent. } }

      Dave