Reputation: 1514
How is it possible to print output to console with print
function without wordwrap? It seems that automatically it wraps the long words.
I'm trying to write some easy text viewer so I need your hints :) Should different function be used or some mode changed?
Upvotes: 0
Views: 319
Reputation: 53498
This is less perl, more unix. Perl doesn't wrap lines, your terminal is doing so.
However, I'd start with something like Term::ReadKey
which can use GetTerminalSize();
And then use that to format my 'print' statements.
e.g.
use Term::ReadKey;
my ( $width_chars ) = GetTerminalSize();
And then use that to truncate the line, probably using substr
.
E.g.
print substr ( $line, 0, $width_chars ),"\n"
Upvotes: 2