Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I find out what Perl IO Layer(s) a given filehandle has?

Tags:

perl

Is it possible to find out what IO Layer a Perl filehandle has on it?

For example:

open(my $fh, '<:encoding(UTF-8)', $filename)
    or die "Unable to open '$filename': $!";

say io_layer($fh); # prints "encoding(UTF-8)"
like image 208
Kaoru Avatar asked Jun 13 '14 19:06

Kaoru


1 Answers

The following returns the names of the PerlIO layers on a filehandle.

my @layers = PerlIO::get_layers($fh); # Or FH, *FH, "FH".

more details in PerlIO doc.

like image 155
agamike Avatar answered Oct 13 '22 22:10

agamike