in reply to Fcntl constants missing

I think this is how you can do it:

eval { $SYSOPEN_MODE |= &{ $Fcntl::{'O_NONBLOCK'} }; }; if($@) { if($@ =~ /Your vendor has not defined/) { # OK, we don't have O_NONBLOCK } else { die "$@"; # Rethrow exception, must be something different } }

-- 
Ronald Fischer <ynnor@mm.st>

Replies are listed 'Best First'.
Re^2: Fcntl constants missing
by nwetters (Initiate) on Mar 24, 2009 at 13:16 UTC

    it looks like the problem is $AUTOLOAD in Fcntl, which throws the error when the symbol table is queried.

    looping through the symbol table doesn't throw the same error:

    foreach my $sym (keys $Fnctl::){ if($sym eq 'O_NONBLOCK'){ $SYSOPEN_MODE |= &{ $Fcntl::{'O_NONBLOCK'} }; } }

    however, this doesn't work with another constant, O_NOCTTY