So Amias said:

>
> Fcntl returning 0 but true like the dog it is.
>
> toodle-pip
> Amias
>

and Max said:

On Thu, Oct 23, 2008 at 11:52 AM, max psykx <[EMAIL PROTECTED]> wrote:
> When you 'use IO::file' it checks to see if the there as a variable
> available from 'File::Temp' before it defines &O_CREAT then the
> ternary if provides out put the line below is my proof if this
>
>
> $perl -e 'use IO::File; use File::Temp qw(tempfile);  print defined
> &O_CREAT ? "yes\n" : "no\n"'
>
> no
>
> Max

Here's my version:

File::Temp uses Fcntl and hence imports O_CREAT etc.; it also contains the line

    my $OPENFLAGS = O_CREAT | O_EXCL | O_RDWR;

which RUNS O_CREAT etc. Fcntl defines the constants on demand using an
AUTOLOAD, so this use of O_CREAT causes the constant to become
defined. File::Temp doesn't export these constants, though, so in
package main we still don't have O_CREAT.

IO::File does export them:

    eval {
        # Make all Fcntl O_XXX constants available for importing
        require Fcntl;
        my @O = grep /^O_/, @Fcntl::EXPORT;
        Fcntl->import(@O);  # first we import what we want to export
        push(@EXPORT, @O);
    };

So in combination, File::Temp causes the constants to become defined
and IO::File exports them into your package. With either one of those
by itself, you don't get a defined constant in your package.

Thanks for joining in chaps :-)

Alex
_______________________________________________
BristolBathPM mailing list
[email protected]
http://mailman.bristolbath.org/mailman/listinfo/bristolbathpm

Reply via email to