develooper Front page | perl.perl5.porters | Postings from October 2014

[perl #122975] B::IO::IoTYPE values of "a" and "+" are mutually exclusive

From:
Nathan Glenn
Date:
October 15, 2014 11:56
Subject:
[perl #122975] B::IO::IoTYPE values of "a" and "+" are mutually exclusive
Message ID:
rt-4.0.18-13039-1413299641-671.122975-75-0@perl.org
# New Ticket Created by  Nathan Glenn 
# Please include the string:  [perl #122975]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=122975 >


I want to retrieve the mode that a handle was opened in via B, but the values of "append" and "read and write" are mutually exclusive, so information is lost if a handle is opened with both and then inspected via B. To demonstrate:

use strict;
use warnings;
use B;
use File::Temp;
my $temp_fh = File::Temp->new();
$temp_fh->close();
my $filename = $temp_fh->filename;
foreach my $mode (qw( < > >> +< +> +>> )) {
    open(my $fh, $mode, $filename) || die "Can't open temp file in mode $mode: $!";
    my $type =  B::svref_2object($fh)->IO->IoTYPE();
    print "$mode -- $type\n";
}

The above prints the below:

< -- <
> -- >
>> -- a
+< -- +
+> -- +
+>> -- a

These all make sense except for the last one, which should be "a+" or something.




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