Perl: Get terminal width

If you need a fast and simple way to get the terminal width in Perl core use Term::ReadKey. This is almost certainly faster and better than shelling out to tput cols.

sub get_terminal_width {
    my @x      = Term::ReadKey::GetTerminalSize();
    my $width  = $x[0] || 0;

    return $width;
}


Note: Replies will be formatted with PHP Markdown Extra syntax.

Name: Email (Not Required):
 
Logged IP: 216.73.216.15
To prevent spam please submit by clicking the kitten: