in reply to Re^4: open undef
in thread open undef

My position is that what happens in the first case is the proper thing to do.

The first and third case are behaving correctly. The middle one should behave like the first, but open can't tell the difference between an unallocated array element and undef (since they both return the undef).

the addresses seem to differ - why is that?

I believe memory addresses are varied between program runs to minimize the damage from certain types of attacks. If you did both Dump in the same run, they would have the same address.

$ perl -MDevel::Peek -e'Dump($ARGV[0]); Dump(undef);' SV = NULL(0x0) at 0xf78148 REFCNT = 2147483639 FLAGS = (READONLY,PROTECT) SV = NULL(0x0) at 0xf78148 REFCNT = 2147483639 FLAGS = (READONLY,PROTECT) $ perl -MDevel::Peek -e'Dump($ARGV[0]); Dump(undef);' SV = NULL(0x0) at 0xbe6148 REFCNT = 2147483639 FLAGS = (READONLY,PROTECT) SV = NULL(0x0) at 0xbe6148 REFCNT = 2147483639 FLAGS = (READONLY,PROTECT)

Replies are listed 'Best First'.
Re^6: open undef
by morgon (Priest) on Aug 02, 2018 at 20:37 UTC
    Ah ok, that makes sense.

    As for the behaviour in the middle case I must say that I consider that to be bug. Your explanation makes sense, but it is a bug nevertheless - would you agree?

      Yes, it's a known bug.

        So do you know if it will be fixed?

        It bit me today when I was consolidating several stand-alone scripts into one script when I forgot to change one occurence of $ARGV[0] and did not get the error I expected.

        Would reporting it again speed up anything?

Re^6: open undef
by BillKSmith (Monsignor) on Aug 07, 2018 at 14:20 UTC
    ForgotPasswordAgain quoted the applicable documentation. Based on this quote, I would expect all three cases to create the temporary file. I agree that only the third case should. The quoted specification should be changed to reflect this.
    Bill

      The documentation says that using "undef" (not "an undefined value") creates the temporary file, but the first two cases don't use undef. As such, according to the documentation, only the third case should create the temporary file.

        Got it! I missed the significance of the underscore under "undef" in the document.
        Bill