Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^3: ztk-webcam snapshot-grabber

by Anonymous Monk
on Jul 21, 2011 at 02:25 UTC ( [id://915788]=note: print w/replies, xml ) Need Help??


in reply to Re^2: ztk-webcam snapshot-grabber
in thread ztk-webcam snapshot-grabber

Would you explain what "$|++" meaning is in the code? Thanks

Its like $foo++ except working on the variable $| , a reall shell-ish (or hack-ish) way to turn autoflush on, as in

use IO::Handle; print 1; # doesn't print, puts 1 in the buffer STDOUT->autoflush(1) print 1; # prints 1 immediately (and the previously buffered 1) print "\n2\n"; # \n forces a flush
Tutorials: Input and Output: Suffering from Buffering?

Replies are listed 'Best First'.
Re^4: ztk-webcam snapshot-grabber
by PhillipHuang (Beadle) on Jul 22, 2011 at 08:35 UTC

      Just think me as a kid. When i run the below script, it really print 1(not as your comment).

      Well, that is not my code ;) buffering means printing doesn't happen immediately, it is delayed, barring a crash of some sort, it will happen eventually, like when a program exits, when all buffers are flushed .

      Try this instead

      use IO::Handle; print "\n2\n"; # \n forces a flush, 2 printed immediately print 1; # doesn't print, puts 1 in the buffer sleep 1; # still nothing printed STDOUT->autoflush(1); # buffered 1 printed print "\n"; # prints immediately sleep 1; print 1; # prints 1 immediately sleep 1; print "\n";

      Without sleep, you wouldn't notice the buffering, and without sleep, I forget to add sleep or test my original code:) but its ok since I linked to the tutorial for you to read, and run its code, and believe what it says is true :) because it is :) I did, I did taw a puddy tat

      Anonymous Tweety Pie

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-04-25 16:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found