use warnings; use strict; use Win32::Console 'STD_OUTPUT_HANDLE'; use Data::Dump qw(dd); 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; print qq($left, $top, $right, $bottom \n); 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 } ''xmsg; dd $rect; print qq{======\n$rect\n======\n}; #### c:\@Work\Perl\monks\gpmathis>perl -wMstrict -le "print qq{\nHow old are you?: }; my $age = ; my $year = 2017 - $age; print qq{You were born in $year\n}; " How old are you?: 42 You were born in 1975 c:\@Work\Perl\monks\gpmathis>perl cap_con_1.pl 0, 0, 99, 59 " c:\\\@Work\\Perl\\monks\\gpmathis>perl -wMstrict -le \"print qq{\\nHow old are you?: }; my \$age = ; my \$year = 2017 - \$age; print qq{You were born in \$year\\n}; \" How old are you?: 42 You were born in 1975 c:\\\@Work\\Perl\\monks\\gpmathis>perl cap_con_1.pl 0, 0, 99, 59" ====== c:\@Work\Perl\monks\gpmathis>perl -wMstrict -le "print qq{\nHow old are you?: }; my $age = ; my $year = 2017 - $age; print qq{You were born in $year\n}; " How old are you?: 42 You were born in 1975 c:\@Work\Perl\monks\gpmathis>perl cap_con_1.pl 0, 0, 99, 59 ====== c:\@Work\Perl\monks\gpmathis> #### @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 #### c:\@Work\Perl\monks\gpmathis>--- c:\@Work\Perl\monks\gpmathis>perl -wMstrict -le "print qq{\nHow old are you?: }; my $age = ; my $year = 2017 - $age; print qq{You were born in $year\n}; " How old are you?: 42 You were born in 1975 c:\@Work\Perl\monks\gpmathis>capsess ====== c:\@Work\Perl\monks\gpmathis>--- c:\@Work\Perl\monks\gpmathis>perl -wMstrict -le "print qq{\nHow old are you?: }; my $age = ; my $year = 2017 - $age; print qq{You were born in $year\n}; " How old are you?: 42 You were born in 1975 ====== c:\@Work\Perl\monks\gpmathis>