Mailing List Archive

Problem parsing O_RDWR+O_CREAT. Was Re: tie() NDBM doesn't create the file(s)
Harlan Harris <harlan@cs.wisc.edu> wrote:

> >Therefore, for L<ndbm(3)>, L<sdbm(NA)> and L<DB(3)> you need
> >to C<use Fcntl>, and supply constants for the I<flags> such as
> >C<O_RDWR+O_CREAT> or C<O_RDONLY>.
>
> Trying...
>
> Worked! (Needed "|" rather than "+" for the 4th arg, though.)

Ouch! you're right.

I've not seen this hefalump trap before - another nail in the coffin of
the pseudo-constants exported from modules.

Is this some subtle mis-feature of parsing, or an old-fashioned bug?
(Sorry, once again, that my 5.002b1 is inaccessible to me...)

use Fcntl;
printf "%d %d\n", O_RDWR|O_CREAT, O_RDWR+O_CREAT;

prints
66 2

Using &O_RDWR+&O_CREAT, or O_CREAT()+O_RDWR(), gets the right answer.

Ian
Re: Problem parsing O_RDWR+O_CREAT. Was Re: tie() NDBM doesn't create the [ In reply to ]
According to Ian Phillipps:
> use Fcntl;
> printf "%d %d\n", O_RDWR|O_CREAT, O_RDWR+O_CREAT;
>
> prints
> 66 2

Once Fcntl.pm is updated to use prototypes, that trap will be closed.
--
Chip Salzenberg, aka <chs@nando.net>
"Hey, it's the Miss Alternate Universe Pageant!"
-- Crow T. Robot, MST3K: "Stranded In Space"