Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^4: ztk-webcam snapshot-grabber

by PhillipHuang (Beadle)
on Jul 22, 2011 at 08:35 UTC ( [id://916081]=note: print w/replies, xml ) Need Help??


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

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

phillip@athens:/tmp$ perl -e 'use IO::Handle;print 1;'

And thanks for the reply(Re^3: ztk-webcam snapshot-grabber), I find "$_" mean in http://perldoc.perl.org/perlvar.html. Is its printing "1" caused by there's nothing to be flush in buffer?

Replies are listed 'Best First'.
Re^5: ztk-webcam snapshot-grabber
by Anonymous Monk on Jul 22, 2011 at 09:08 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://916081]
help
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found