@REM = 'windows batch wrapper @ECHO off perl %0.bat goto BYEBYE ' if 0; use warnings; use strict; use Win32::Console 'STD_OUTPUT_HANDLE'; my $con_current = Win32::Console->new(STD_OUTPUT_HANDLE); $con_current or die 'new Win32::Console failed'; my ($left, $top, $right, $bottom) = $con_current->Window; my $width = $right - $left + 1; my $rect = $con_current->ReadRect($left, $top, $right, $bottom); $rect or die 'read Win32::Console failed'; $rect =~ s{ \0\a\0 } ''xmsg; $rect =~ s{ [ ]+ \z } ''xms; $rect =~ s{ .{$width} \z } ''xms; print qq{======\n$rect\n======\n}; __END__ :BYEBYE