|Perl Monk, Perl Meditation|
"Exporting" Terminal Size to Piped Command?by PetaMem (Priest)
|on Jul 22, 2008 at 20:31 UTC||Need Help??|
PetaMem has asked for the
wisdom of the Perl Monks concerning the following question:
I've been using Term::Size - and while hunting the problem described herein also Term::Size::Perl for detecting the size of the terminal my perl script is running in. I'm only interested in the chars (columns, rows). Everything woks fine, when you start the script in a shell: Both columns and rows are displayed correctly by both aforementioned modules.
Unfortunately, both modules fail if you have your script started from within another script through a pipe:
$rcmd being the name of the script that shall detect the terminal size. Unfortunately in this case, both modules return empty values for columns and rows. I'm using
to get the terminal dimensions.
Now that's of course totally unsatisfying and horrible and makes me whine. :-) Is there any way, how to pass terminal size elegantly to the piped command. (By elegantly I mean not the obvious way of putting these data on the command line - it should be transparent for the user).
Which seems to work pretty well in all cases where the old (STDOUT) worked before PLUS in those where it didn't. Also, this is able to cope with the </dev/null redirection.