Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^8: Need sleep walking help

by Marshall (Canon)
on Feb 02, 2017 at 09:14 UTC ( [id://1180831]=note: print w/replies, xml ) Need Help??


in reply to Re^7: Need sleep walking help
in thread Need sleep walking help

Ok, fair enough. There are some fine details here, one of which is whether the std output is going to a terminal or not? I did a copy and paste from my dev environment which is not exactly the same as running from the command line directly.

My demo is not "bullet proof", but I think it gives the idea of what can happen.

Thanks for your good points.

Replies are listed 'Best First'.
Re^9: Need sleep walking help
by haukex (Archbishop) on Feb 02, 2017 at 09:22 UTC

    Hi Marshall,

    I did a copy and paste from my dev environment which is not exactly the same as running from the command line directly.

    Sure, that's a possibility. Even something as seemingly simple as perl foo.pl | grep bar or even perl foo.pl | cat on the terminal will cause Perl to turn off line buffered mode on STDOUT and cause the need for $|++ if you want "live" output.

    Regards,
    -- Hauke D

      Yes, that is what is happening. I very seldom run Perl directly from the command line without redirecting output to a file.

      I do most of my work on Windows and for reasons that mystify me, writing to the command window terminal is super duper slow. Many of my programs are written as Unix style filters and often they will become I/O limited to the STDOUT terminal speed without STDOUT and/or STDERR re-direction to a file. Other O/S'es that I've worked on just fly 5K lines to the terminal in a blur - but not Windows. Windows must have some sort of max speed throttle when writing to the command window. If anybody knows to increase that speed, I'd like to know!

      I use Textpad for Perl dev on Windows. It captures STDERR and STDOUT to a new edit window when I "push the Perl "go" button". I come across the need for $|=1; all the time and I've gotten used to that quirk so much that I don't think about it much.

      I think this completely explains my results.

        Hi Marshall,

        I just wanted to point out the -t operator that tests whether a filehandle is connected to a TTY. I don't know if this is the same mechanism that Perl uses to decide whether to use line-buffered mode or not, and I dimly remember reading somewhere that the -t test isn't always reliable, but anyway, this snippet would probably also confirm the issue.

        $ perl -e 'warn "STDOUT ".(-t STDOUT?"IS":"is NOT")." a TTY\n"' STDOUT IS a TTY $ perl -e 'warn "STDOUT ".(-t STDOUT?"IS":"is NOT")." a TTY\n"' | cat STDOUT is NOT a TTY

        Regards,
        -- Hauke D

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1180831]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2024-04-20 04:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found