develooper Front page | perl.perl5.porters | Postings from September 2018

[perl #133505] open() dies for invalid modes, instead of returningundef, as documented

Thread Previous | Thread Next
From:
R. Diez
Date:
September 11, 2018 04:47
Subject:
[perl #133505] open() dies for invalid modes, instead of returningundef, as documented
Message ID:
rt-4.0.24-6379-1536405492-1467.133505-75-0@perl.org
# New Ticket Created by  R. Diez 
# Please include the string:  [perl #133505]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=133505 >




The following code:



my $memFileContents;


open( my $memFile, 'ERROR_HERE', \$memFileContents )
            or die "Cannot create in-memory file: $!\n";


yields this error message:


Unknown open() mode 'ERROR_HERE' at main.pl line 8.


The error message seems like a run-time error, and not a compilation error. However, the documentation states: "Open returns nonzero on success, the undefined value otherwise." Therefore, open() should not die itself, but return undef, and hopefully also set $! accordingly.



I tested it with Perl version v5.22.1, and also online with this site, which has version v5.24.2:

http://www.compileonline.com/execute_perl_online.php


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About