You don't need to close the old STDOUT and create a new one with the CP437 encoding; you can just binmode the existing STDOUT:
C:\Users\peter.jones\Downloads\TempData\perl>perl -Ilib -e"print qq(\xe4)"
Σ
C:\Users\peter.jones\Downloads\TempData\perl>perl -Ilib -MDOS::Try -e"print qq(\xe4)"
ä

vs

C:\Users\peter.jones\Downloads\TempData\perl>perl -e"print qq(\xe4)"
Σ
C:\Users\peter.jones\Downloads\TempData\perl>perl -e"binmode STDOUT, ':encoding(Cp437)'; print qq(\xe4)"
ä

And the reason your example doesn't work in your test is the same reason that you wrote the module: you need to have the right encoding on the output of your test script as well as the code of the `...`.

#!perl

use strict;
use warnings;
my $result = `perl -Ilib -MDOS::Try -e"print qq(\xe4)"`;
print "first test: $result\n";

use lib 'lib';
require DOS::Try;
print "second test: $result\n";
__END__
first test: Σ
second test: ä

You can see more if you hex dump the bytes being output from the two variants of the oneliner:

C:\Users\peter.jones\Downloads\TempData\perl>perl -e"print qq(\xe4)" | perl -e "print unpack 'H*',$_ for <>"
e4
C:\Users\peter.jones\Downloads\TempData\perl>perl -e"binmode STDOUT, ':encoding(Cp437)'; print qq(\xe4)" | perl -e "print unpack 'H*',$_ for <>"
84

In reply to Re: print in CMD window by pryrt
in thread print in CMD window by BillKSmith

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.