Perl(3pm)

πŸ’– Term::Size::Perl β€” the manual, but make it a group chat πŸ’–

okay bestie, this is the user-contributed Perl documentation for Perl(3pm), a.k.a. Term::Size::Perl πŸŽ€ β€” the Perl extension for retrieving terminal size (Perl version). yes it's a mouthful, yes it's iconic, let's go ✨

What is this even β€” Term::Size::Perl β€” a Perl extension for retrieving terminal size, Perl version. that's the whole vibe πŸ¦‹


✨ SYNOPSIS ✨

like, just look at it, it's so clean πŸ˜­πŸ’…

use Term::Size::Perl;

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

🌸 DESCRIPTION 🌸

okay so. this is yet another implementation of Term::Size πŸ‘‘ β€” and the glow-up is that it's now in pure Perl, with the one (1) exception of a C probe that gets run at build time. lowkey iconic behavior fr fr 🧚

πŸ’« FUNCTIONS πŸ’«

🫢 chars

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

chars hands you the terminal size in units of characters, and it does it for whatever filehandle $h you're pointing at πŸ’–

if you straight up don't pass an argument? no worries, bestie, it falls back to *STDIN{IO} πŸ™ˆ

and in scalar context it gives you just the terminal width. no cap πŸ“βœ¨

πŸ¦‹ pixels

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

pixels</purl> β€” wait, pixels β€” returns the terminal size in units of pixels for the given filehandle $h πŸŽ€

argument omitted? again, *STDIN{IO} steps in like the main character it is πŸ’…

scalar context β†’ terminal width only. same energy as chars, different unit ⭐

⚠️ heads up though: on many systems with character-only terminals, this is gonna return "(0, 0)" 😭 not a bug, just the vibe of that hardware. don't come for me.

πŸ”₯ SEE ALSO πŸ”₯

the origin story!!! it all began with Term::Size by Tim Goodwin 🌈🫢 you may want to have a lil look at:

  • Term::Size
  • Term::Size::Win32
  • Term::Size::ReadKey

πŸ“£ bugs β†’ please report them via GitHub, over at <https://github.com/aferreira/cpan-Term-Size-Perl/issues> πŸ›πŸ’Œ

and pro tip, when you're reporting bugs, it may be helpful to attach the Params.pm that the probe generates at build time πŸ‘‘ (iykyk)


πŸ’œ AUTHOR πŸ’œ

Adirano Ferreira, <ferreira@cpan.org> β€” thank u king 🫑✨


Copyright (C) 2006-2007, 2017-2018 by Adriano Ferreira

this library is free software πŸ•ŠοΈ you can redistribute it and/or modify it under the same terms as Perl itself. slay, legally speaking πŸ’…πŸ“œ


and that's the whole page, bestie!! this was perl v5.42.3, dated 2026-08-19, filed under Perl(3pm) β€” go get those terminal dimensions, u got this πŸŒŸπŸ’–βœ¨

πŸ“¦ where this page comes from