in reply to Weird screen output in my AceShell module

The "←[0J" you are seeing is actually, as ikegami said, a mis-renderend escape sequence.  The "←" is what happens when the command window tries to directly print an escape (\e).

It's probably unnecessary to install 'Win32::CONSOLE::ANSI', though, as it's already part of the ActiveState Perl core (at least in the latest 5.8.7 version).  Here's an experiment you can try.  I've changed the escape sequence to the one for clearing the screen, "\e[H\e[J", which is very easy to see when it occurs.  (It also works in Linux and other places where the ANSI escape sequences are honored):

use strict; use warnings; $|++; print "\e[H\e[J"; print "\nPress <RETURN> to clear the screen: "; <STDIN>; require Win32::CONSOLE::ANSI; print "\e[H\e[J";

The first time time it prints "\e[H\e[J", it doesn't handle it gracefully, and you'll see escape rendered as "←" again:  "←[H←[J".  The second time, though, since you are now using "Win32::CONSOLE::ANSI", the screen will be cleared.


s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/

Replies are listed 'Best First'.
Re^2: Weird screen output in my AceShell module
by Ace128 (Hermit) on Jul 15, 2006 at 20:13 UTC
    Hmm, seens that I fooled myself little. Apparently I loaded that in some Constants.pm I've made. However, it still doesn't seem to work with the AceShell.pm module, even if I explicitly add this in the module:
    # This so one can use \e ourselfes... on both Linux and Windows! Else # the Win32::Console::ANSI have its on functions for outputting in col +or! if ($^O eq "MSWin32") { eval { require Win32::Console::ANSI; }; } elsif ($^O eq "Linux") { eval { require Term::ANSIColor; }; } use Term::ANSIScreen qw/:color :cursor :screen :keyboard/; ...
    After some testing, I seem to need to do this before loading in the Term::ANSIScreen module.
      elsif ($^O eq "Linux") { eval { require Term::ANSIColor; }; }

      is useless. You're using the functions from Term::ANSIScreen instead of those from Term::ANSIColor. Term::ANSIColor is a subset of Term::ANSIScreen, not the non-Windows equivalent of Win32::Console::ANSI.

      Furthermore, you can simplify your program using the if pragma:

      # Load ANSI driver if running in Windows. use if $^O eq 'MSWin32', 'Win32::Console::ANSI'; use Term::ANSIScreen qw/:color :cursor :screen :keyboard/; ...

      Using the simpler code shouldn't fix anything, but since it will load Win32::Console::ANSI at compile time as if you had said use Win32::Console::ANSI;, it might.

      Update: Added missing quotes as per reply.

        Ok, seems to be working now though. One thing I also noticed I missed was doing a function call like this: $self->functionCall() instead of just functionCall(); Stupid.

        Also, I get this with your code:
        Bareword "Win32::Console::ANSI" not allowed while "strict subs" in use at Constants.pm line 18.
        Execution of Constants.pm aborted due to compilation errors.