in reply to Re^3: Error binmode() on unopened filehandle
in thread Error binmode() on unopened filehandle
You can't switch modes in the midst of a file.
You sure can:
use warnings;
use strict;
use utf8;
use Data::Dumper;
$Data::Dumper::Useqq=1;
print join(", ",PerlIO::get_layers(*DATA)),"\n";
print Dumper( scalar <DATA> );
binmode DATA;
print join(", ",PerlIO::get_layers(*DATA)),"\n";
print Dumper( scalar <DATA> );
__DATA__
H∃llⓄ, 🗺!
H∃llⓄ, 🗺!
Output:
unix, perlio, utf8 $VAR1 = "H\x{2203}ll\x{24c4}, \x{1f5fa}!\n"; unix, perlio $VAR1 = "H\342\210\203ll\342\223\204, \360\237\227\272!\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Error binmode() on unopened filehandle
by Marshall (Canon) on May 03, 2020 at 21:54 UTC |