Bloehdian has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks,

probably a quite simple question for most of You, but I've just got stuck on it:

In one of my progs I have the following

if ( ! defined $test && $! == EWOULDBLOCK ) {

which, since use strict is effect gives the error message

"Bareword "EWOULDBLOCK" not allowed while "strict subs" in use"

How can I test $! anyways?

Cheers

Bloehdian

Replies are listed 'Best First'.
Re: Testing $! when use strict is in effect
by Corion (Patriarch) on Oct 20, 2016 at 18:45 UTC

    The error is not about $! but about EWOULDBLOCK. You will need to import it, most likely from Errno.

      Thx, works ;-)

Re: Testing $! when use strict is in effect
by Dallaylaen (Chaplain) on Oct 23, 2016 at 22:16 UTC
    You can check condition "error EFOO is the case" via the %! magic hash:
    if ($!{EWOULDBLOCK} ) { # would block };
    Search for %ERRNO in perldoc perlvar.