Reputation: 25117
Where do the additional empty lines come from when printing this script in a windows terminal?
use strict;
use warnings;
use 5.10.0;
use Term::Size::Any qw(chars);
my $w = ( chars( \*STDOUT ) )[0];
my $string = "Y" x $w;
say $string;
say $string;
say $string;
say $w;
The output from the MSWindows console:
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
80
The output from the Linux console:
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
80
Upvotes: 2
Views: 373
Reputation: 3631
Different terminals and terminal emulators/ consoles work differently if you write to the last column on the screen.
This program sleeps between writing the long line and the LF
use strict;
use warnings;
use 5.10.0;
my $w = shift // 80 ;
my $string = "Y" x $w;
$|++; # flush buffer on every write
print $string ;
print "\n" ;
print $string ;
sleep 2 ;
print "\n" ;
print "Finished\n" ;
On windows you see the following while sleeping.
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
[bottom of screen]
Whilst on Linux
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
[bottom of screen]
There is probably more to it than this, but hopefully this will satisfy your curiosity!
Upvotes: 2
Reputation: 386386
I am interested in why the script behaves differently on Windows.
Because the two terminals you are using are different programs.
Upvotes: 0
Reputation: 362
Instead of 'say' use 'print'. I think output will be same on both Linux and Windows.
Upvotes: 0