I want to get a terminal's size. I tried to use Term::Size
or Term::Screen
but it does not work (cannot install it or can't locate). Is it any alternative way to get terminal size in perl? For example without use additional modules?
Asked
Active
Viewed 36 times
0

Developus
- 1,400
- 2
- 14
- 50
-
1`cannot install it or can't locate`. Do share the error message. – Chankey Pathak Dec 07 '16 at 18:29
-
2http://stackoverflow.com/questions/1782107/how-do-i-retrieve-the-terminal-width-in-perl – stevieb Dec 07 '16 at 18:29
-
Error message for example: `Uncaught exception from user code: Can't locate Term/Size/Any.pm in @INC (@INC contains: C:/../../Desktop/../..E:/Dwimperl/perl/site/lib E:/Dwimperl/perl/vendor/lib E:/Dwimperl/perl/lib .) at ..` – Developus Dec 07 '16 at 18:30
-
1That message means you put `use Term::Size::Any;` in your code but didn't install the Term::Size::Any module (or it's installed somewhere that perl can't find it). Did you try installing it? – ThisSuitIsBlackNot Dec 07 '16 at 18:33
-
Ok, but when I installed it, I add: `use Term::Size::Any qw( chars pixels ); (my $columns, my $rows) = chars *STDOUT{IO};` and use this variables like this: `if($height > $cols || $width > $rows) {..}`, I get: `Global symbol "$cols" requires explicit package` – Developus Dec 07 '16 at 18:37
-
2That's a totally different issue. You declared the `$columns` variable but used `$cols` in your `if` statement. – ThisSuitIsBlackNot Dec 07 '16 at 18:43