Term::Size::Any(3pm)

πŸ“¦
version 0.002 Β· 6 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

Term::Size::Any β€” bestie, it retrieves terminal size. That's it, that's the whole vibe ✨

This is the Term::Size::Any(3pm) page, in case you were wondering which one you were reading. πŸŽ€


🌸 SYNOPSIS 🌸

# the traditional way
use Term::Size::Any qw( chars pixels );

($columns, $rows) = chars *STDOUT{IO};
($x, $y) = pixels;

okay so look at that. two little functions, one import, and you know how big your terminal is. slay. πŸ’…


✨ DESCRIPTION ✨

So here's the tea, bestie: this module is a unified interface for getting your terminal size. What does that mean? It goes and loads one module out of a list of known alternatives, and each of those implements some way of getting the terminal info you want. Whichever one gets loaded is the one that actually does the job, on behalf of Term::Size::Any. Like, it's the manager, the other module is the one clocking in. πŸ‘‘

Which means Term::Size::Any depends on one of these modules being available:

Term::Size           (soon to be supported)
Term::Size::Perl
Term::Size::ReadKey  (soon to be supported)
Term::Size::Win32

Now, the behaviour: this release fallbacks to Term::Size::Win32 if you're running on Windows 32 systems. For every other platform, it uses the first of Term::Size::Perl, Term::Size, or Term::Size::ReadKey that loads successfully. πŸ™ˆ

And to be fully honest with you (the author says so himself): the fallback to Term::Size and Term::Size::ReadKey is disabled, because those two are buggy as of right now. Not me being shady, that's literally in the source. πŸ’€

πŸ¦‹ FUNCTIONS πŸ¦‹

The traditional interface works by importing the functions chars and pixels into the caller's space. So you use the module, you get the functions, you go live your life. 🌈

🌟 chars

($columns, $rows) = chars($h);
$columns = chars($h);

chars returns the terminal size in units of characters, and that's for the given filehandle $h. If you don't pass an argument at all, it uses *STDIN{IO} instead. And if you call it in scalar context? It hands you back just the terminal width. one number, no drama. πŸ’œ

🌟 pixels

($x, $y) = pixels($h);
$x = pixels($h);

pixels returns the terminal size in units of pixels, again corresponding to the given filehandle $h. Omit the argument and it's *STDIN{IO}. Scalar context gives you the terminal width. ✨

Heads up though: many systems with character-only terminals will return (0, 0). So if you get zeros, that's not a you problem, that's just your terminal being like "pixels? never heard of her." 😭

πŸ”₯ SEE ALSO πŸ”₯

It all began with Term::Size by Tim Goodwin. iconic origin story, honestly. You may want to have a look at:

Term::Size
Term::Size::Perl
Term::Size::Win32
Term::Size::ReadKey

🫢 BUGS 🫢

Found a bug? Please reports bugs via CPAN RT, via web at

http://rt.cpan.org/NoAuth/Bugs.html?Dist=Term-Size-Any

or e-mail to

bug-Term-Size-Any@rt.cpan.org

go tell them, they wanna know, fr fr. πŸ“¬


πŸ‘‘ AUTHOR πŸ‘‘

Adriano R. Ferreira, <ferreira@cpan.org>


Copyright (C) 2008-2012 by Adriano R. Ferreira

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


and that's a wrap, bestie!! this page is Term::Size::Any, shipped with perl v5.34.0, dated 2022-06-17. go check your terminal size, you've got this πŸ¦‹πŸ’…βœ¨

πŸ“¦ where this page comes from