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

I just modified a perl program that used DB_File to use Storable instead. When I was done, I removed "use DB_File", and suddenly

Bareword "O_WRONLY" not allowed while "strict subs" in use at ./tview.pl line 331.
Bareword "O_APPEND" not allowed while "strict subs" in use at ./tview.pl line 331.
Bareword "O_CREAT" not allowed while "strict subs" in use at ./tview.pl line 331.

But line 331 is just a sysopen call:

sysopen (BM, "$dir/mainfile.txt", O_WRONLY | O_APPEND | O_CREAT);

As far as I know sysopen doesn't require DB_File -- what's up?

Replies are listed 'Best First'.
Re: bareword in sysopen?
by moritz (Cardinal) on Oct 20, 2008 at 13:24 UTC
    It seems that DB_File exports some constants named O_WRONLY etc. by default.

    Now that they are gone you need to get them somewhere, I guess Fcntl would be an appropriate source.

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: bareword in sysopen?
by periapt (Hermit) on Oct 20, 2008 at 14:07 UTC
    According to the doc page DB_File uses the constants defined in the dbopen function library. A quick web search on "man dbopen" suggest that the constants defined in fcntl.h are part of this library so I would try "use Fcntl" to see if that clears up your errors.

    Interestingly, the doc page indicates that using O_WRONLY as a flag to the open action will produce an error since it doesn't make any sense to open a database for writing only. It's probably a different, non-db, file that is being opened this way.

    PJ
    use strict; use warnings; use diagnostics;
      'it doesn't make any sense to open a database for writing only.'

      Why? Makes perfect sense to me. Its just another data store.

        Mmmmm, you'll have to take that up with the writers of dbopen. That was their reasoning for making O_WRONLY trip an error.

        PJ
        use strict; use warnings; use diagnostics;