morgon has asked for the wisdom of the Perl Monks concerning the following question:
I just stumbled across an (for me) very unexpected behaviour with open:
This prints "no such file or directory", as expected.use strict; my $file; open my $fh, "<", $file or die $!; print "here\n";
But
This prints "here" - i.e. does not raise an exception when called without command-line arguments.use strict; open my $fh, "<", $ARGV[0] or die $!; print "here\n";
And finally
Also does not raise an exception.use strict; open my $fh, "<", undef or die $!; print "here\n";
What is going on here?
I am using 5.26.1.
Many thanks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: open undef
by ForgotPasswordAgain (Vicar) on Aug 02, 2018 at 17:57 UTC | |
by morgon (Priest) on Aug 02, 2018 at 18:13 UTC | |
by ikegami (Patriarch) on Aug 02, 2018 at 20:04 UTC | |
by morgon (Priest) on Aug 02, 2018 at 20:18 UTC | |
by ikegami (Patriarch) on Aug 02, 2018 at 20:24 UTC | |
| |
by haukex (Archbishop) on Aug 02, 2018 at 20:35 UTC | |
by morgon (Priest) on Aug 02, 2018 at 20:40 UTC |