# $ENV{COLUMNS} isn't set when running through putty (unless from within emacs) # GetTerminalSize returns 0 from emacs, but ok from putty # fallback to 72 if the other two methods fail sub get_terminal_width { -t STDOUT && return (GetTerminalSize)[0] || $ENV{COLUMNS} || 72; return 72; }