nwetters has asked for the wisdom of the Perl Monks concerning the following question:
A user of one of my modules (File::Touch) sent me a bug report, complaining that his ActiveState Perl barfed on the following line:
sysopen my $fh,$file,O_WRONLY|O_CREAT|O_NONBLOCK|O_NOCTTY or croak("Can't create $file : $!");
The error message was "Your vendor has not defined Fcntl macro O_NONBLOCK, used at..."
So, I tweaked the code to check whether the Fcntl constant exists in the module's symbol table:
my $SYSOPEN_MODE = O_WRONLY|O_CREAT; if(exists $Fcntl::{'O_NONBLOCK'}){ $SYSOPEN_MODE |= &{ $Fcntl::{'O_NONBLOCK'} }; } if(exists $Fcntl::{'O_NOCTTY'}){ $SYSOPEN_MODE |= &{ $Fcntl::{'O_NOCTTY'} }; }
Strangely, the code causes an error at 'exists $Fcntl::{'O_NONBLOCK'}'. The error message is "Your vendor has not defined Fcntl macro O_NONBLOCK, used at File/Touch.pm line 16." The same error occurs with ActiveState 5.8 and 5.10.
Any ideas?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Fcntl constants missing
by puudeli (Pilgrim) on Mar 24, 2009 at 11:32 UTC | |
by rovf (Priest) on Mar 24, 2009 at 12:10 UTC | |
by puudeli (Pilgrim) on Mar 24, 2009 at 12:36 UTC | |
by rovf (Priest) on Mar 24, 2009 at 12:48 UTC | |
|
Re: Fcntl constants missing
by rovf (Priest) on Mar 24, 2009 at 13:05 UTC | |
by nwetters (Initiate) on Mar 24, 2009 at 13:16 UTC | |
|
Re: Fcntl constants missing
by rovf (Priest) on Mar 24, 2009 at 13:01 UTC |