Re: Using fcntl and |= - "Argument .... isn't numeric in bitwise or ..."



Jim Cochrane wrote:
I'm stumped - trying to get rid of a warning message with code based on
this example snippet from the "Perl Cookbook" book:

Your problem has nothing at all to do with fcntl

"use strict" and "use warnings" would have shown you the problem.

$lags = "";
fcntl(HANDLE, F_GETFL, $flags) or die "Couldn't get flags: $!\n";
$flags |= O_NONBLOCK;

It's $flags which is undefined. You've set $lags, not $flags (and setting it to 0 rather than "" would make far more sense).

You don't have to check for "defined" on the return from
"fcntl".

You aren't even checking the return result from fcntl. You are just ignoring it completely (you're calling it in a void context, i.e. not assigning the return value to anything).



--
Just because I've written it doesn't mean that
either you or I have to believe it.
.



Relevant Pages

  • Question on try/except
    ... While perusing sre.py in the standard library, I came upon this snippet of code in the _compile() function definition: ... p = sre_compile.compile(pattern, flags) ...
    (comp.lang.python)
  • IADsTools SetReplicaSyncAllFlags Question
    ... Hello - I am trying to use the following snippet of code ... I receive an error when I attempt to specify ... I did find a reference to the numeric ... values of those flags and then tried it in the ...
    (microsoft.public.windows.server.scripting)