What is causing $CONSOLE->Attr to not work after capture_exec?
I use terminal color change to highlight errors during production tests.

The issue is that after I use "capture_exec" the colors no longer change. I'm assuming it has something to do with the execution of the code in another instance or something ?.?.

In the code below the output is
WHITE text color white
GREEN text color green
WHITE text color green

Thanks for the help you guys have saved by bacon a ton over the years
Matt-rookie

use strict; use warnings; use IO::CaptureOutput qw/capture_exec/; use Win32::Console; use vars qw($CONSOLE $attr); $CONSOLE = Win32::Console->new(STD_OUTPUT_HANDLE); $attr = $CONSOLE->Attr(); #get current console colors $CONSOLE->Attr($FG_WHITE | $BG_BLACK); #wht text on blk print "white\n"; $CONSOLE->Attr($FG_GREEN | $BG_BLACK); #grn text on blk print "green\n"; my ($stdout, $stderr, $success, $exit_code) = capture_exec( "dir" ); $CONSOLE->Attr($FG_WHITE | $BG_BLACK); #grn text on blk print "white\n";

In reply to IO::CaptureOutput Win32::Console compatibility by elmachin

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.