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

Dear Monks,

Today, I tried Strawberry Perl for the first time. I was trying to run a test script, which works on all Unix/Linux distributions ( I've tried ) and also Cygwin. I downloaded/installed Strawberry Perl--no problem. I checked syntax with '-c' parameter and fixed the minor dos related problems. Then I executed the script and received an error message, something like "Vendor has not implemented Fcntl". My immediate reaction -- No locking. The test is single user, so I removed the 'flock' functions.

Now my real problem, when I reran the script, the defines in 'Fcntl' for using the 'sysopen' function didn't exist. I temporarily fixed the problem by running this on Linux:

perl -e 'use Fcntl;$n=O_CREAT | O_NONBLOCK | O_RDWR;print "$n\n";' Result: 262
I replaced the above defines with '262' and the test worked.

Any ideas for a better solution? Is there a way to test for Strawberry Perl? I use 'uname -a' in *nix.

Thank you

"Well done is better than well said." - Benjamin Franklin

Replies are listed 'Best First'.
Re: How to get 'Fcntl' defines on Strawberry Perl?
by Corion (Patriarch) on Feb 08, 2012 at 12:55 UTC

    When I run the following code:

    perl -wle "use Fcntl;$n=O_CREAT | O_NONBLOCK | O_RDWR;print $n;"

    I get

    Your vendor has not defined Fcntl macro O_NONBLOCK, used at -e line 1.

    ... which is highly likely true, because nonblocking file IO does not exist on Windows, and thus a constant O_NONBLOCK does not exist on Windows. Using the numerical values that are defined on Linux will likely not work for other operating systems because the vendors may (or may not) have defined different values for the symbolic names.

    I recommend that you evaluate your program whether O_NONBLOCK is actually needed. If that feature is acutally needed, you will need to investigate what to do on operating systems where O_NONBLOCK does not exist. If you don't need it, just remove it.

    If this is to be used for sockets (and not generic files), you will need to look up the way to switch a socket to nonblocking IO on Windows. It is some IOCtl that is usually found via Google.

      Corion,

      Thanks, that makes a lot of sense!

      The error message was garbled on the display and not as nicely defined as using it as a one liner. I don't think I need the O_NONBLOCK in Windows. I'll remove it and see if it runs.

      Thank you

      "Well done is better than well said." - Benjamin Franklin