So the answer here is that I have to open "/dev/tty" each time I call it rather than reference my already-open "STDOUT"?

I don't have linux, but no, I don't think that is the answer.

I think part of the answer is to do error checking correctly like the faq entry

I also think using S4 is part of the answer, not being an expert on pack/unpack and not having a /dev/tty, I can't run any tests.

Hmmm....I'm disappointed that I need to open another file handle and can't get the rows & columns associated with my already open FH, "STDOUT", directly...

Sounds premature if you ask me, avoiding abstractions always involves some growing pains :)

Shouldn't STDIN, STDOUT map to fd[0], fd[1] => /dev/pts/1 on some level?

They do

$ perl -le " print fileno($_) for STDIN, STDOUT, STDERR " 0 1 2
See, fd 0,1,2. Now regarding tty, using operator -t to test if filehandle is opened to a tty, you can see 0,1,2 are connected to a tty
$ perl -le " print 0+-t $_ for STDIN, STDOUT, STDERR " 1 1 1
but not when you do redirection, here is STDIN not connected to a tty
$ perl -le " print 0+-t $_ for STDIN, STDOUT, STDERR " < NUL 0 1 1
here is STDIN and STDERR not connected to a tty
$ perl -le " print 0+-t $_ for STDIN, STDOUT, STDERR " < NUL 2> NUL 0 1 0
here is STDOUT not connected to a tty
$ perl -le " print 0+-t $_ for STDIN, STDOUT, STDERR " > out.txt $ cat out.txt 1 0 1
I.e. Shouldn't I be able to use some mapping function on STDOUT to get a file descriptor that's suitable for ioctl?

ioctl says you don't need to, the faq item doesn't, and neither does Term::Size::Any


In reply to Re^3: Failing to get current TTY's rows & columns... by Anonymous Monk
in thread Failing to get current TTY's rows & columns... by perl-diddler

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.