Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

B::IO::IoTYPE values of "a" and "+" are mutually exclusive #14159

Open
p5pRT opened this issue Oct 14, 2014 · 1 comment
Open

B::IO::IoTYPE values of "a" and "+" are mutually exclusive #14159

p5pRT opened this issue Oct 14, 2014 · 1 comment

Comments

@p5pRT
Copy link

p5pRT commented Oct 14, 2014

Migrated from rt.perl.org#122975 (status was 'new')

Searchable as RT122975$

@p5pRT
Copy link
Author

p5pRT commented Oct 14, 2014

From @garfieldnate

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants