in reply to open undef shift

Another variant to consider:
>perl -wMstrict -le "sub huh41 { my $nullstring = ''; my $huh = open my $fh, '>', $nullstring or die $!; $huh += print $fh 'huh1'; $huh += close $fh; } print huh41(); " No such file or directory at -e line 1.

Replies are listed 'Best First'.
Re^2: open undef shift
by ikegami (Patriarch) on Oct 03, 2009 at 18:49 UTC
    The OP wasn't clear, but I believe the question is "Why do some means of obtaining an undefined value behave differently than others?" (answer), and perhaps "What happens when one passes undef as the file name to open?" (answer).
      My intention was only to offer another datapoint.

      I found it interesting that a lexical scalar initialized to the empty string behaved the same (minus the warning) as a virgin lexical. This behavior seems reasonably explained in ikegami's Re^2: open undef shift above.

        I found it interesting that a lexical scalar initialized to the empty string behaved the same (minus the warning) as a virgin lexical.

        Why? What file do you expect undef to find when it's not treated specially?

        Seems to me your data point is nothing more what the OP set forth in his question: an initialised scalar isn't treated specially. Thus my explanation.