Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3697774
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:54:03+00:00 2026-05-19T04:54:03+00:00

When using binmode, should I pop the layers from a possibly previous used binmode?

  • 0

When using binmode, should I pop the layers from a possibly previous used binmode?

#!/usr/bin/env perl
use warnings;
use 5.012; 
use autodie;

open my $tty, '>:encoding(utf8)', '/dev/tty'; # ...
close $tty;
open $tty, '>:encoding(latin1)', '/dev/tty'; # ...
close $tty;
open $tty, '>:encoding(utf8)', '/dev/tty'; # ...
close $tty;
open $tty, '>:encoding(latin1)', '/dev/tty'; # ...
close $tty;

open $tty, '>:bytes', '/dev/tty';
say "@{[ PerlIO::get_layers( $tty ) ]}"; # unix perlio
close $tty;

say "----------------------------------------";

binmode STDOUT, ':encoding(utf8)'; # ...
binmode STDOUT, ':encoding(latin1)'; # ...
binmode STDOUT, ':encoding(utf8)'; # ...
binmode STDOUT, ':encoding(latin1)'; # ...

binmode STDOUT, ':bytes';
say "@{[ PerlIO::get_layers( *STDOUT ) ]}"; # unix perlio encoding(utf8) /
# utf8 encoding(iso-8859-1) utf8 encoding(utf8) utf8 encoding(iso-8859-1)


binmode STDOUT, ':pop:pop:pop:pop:bytes';
say "@{[ PerlIO::get_layers( *STDOUT ) ]}"; # unix perlio

.

#!/usr/bin/env perl
use warnings;
use 5.012;
use autodie;

open my $tty, '>:encoding(utf8)', '/dev/tty'; # ...
close $tty;

open $tty, '>:raw', '/dev/tty';
say "@{[ PerlIO::get_layers( $tty ) ]}"; # unix
close $tty;

say "----------------------------------------";

binmode STDOUT, ':encoding(utf8)'; # ...

binmode STDOUT, ':raw';
say "@{[ PerlIO::get_layers( *STDOUT ) ]}"; # unix perlio

binmode STDOUT, ':pop:raw';
say "@{[ PerlIO::get_layers( *STDOUT ) ]}"; # unix
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T04:54:03+00:00Added an answer on May 19, 2026 at 4:54 am

    :pop is required to pop real layers, such as :encoding(...). So yes, if you want to replace a real layer by another one, then you’ll have to :pop.

    But note that pushing :raw actually results in a series of pop… And :perlio automatically inserts :unix underneath. So the exact number of pops really depends on the current layers.

    As the documentation says itself:

    A more elegant (and safer) interface is needed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

#!/usr/bin/perl use CGI ':standard'; use CGI::Carp qw(fatalsToBrowser); my $files_location; my $ID; my @fileholder; $files_location
I'm trying to output an image from RRD Tool using Perl. I've posted the
Using perl 5.8.8 on windows server I am writing a perl cgi script using
How do perl strings represented internally? What encoding is used? How do I handle
Using mercurial, I've run into an odd problem where a line from one committer
Using Java,I have to fetch multiple sets of values from an XML file to
I am using Perl to load some 'macro' files. These macros can, however, be
Using the http://www.ifans.com/forums/showthread.php?t=132024 post from another question i am allowing the user to enter
Using Java, how can I extract all the links from a given web page?
I want to read UTF-8 input in Perl, no matter if it comes from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.