Easily plot realtime data (via Perl and GnuPlot)
users.softlab.ntua.gr
users.softlab.ntua.gr
[0] http://stackoverflow.com/questions/196754/what-does-selectse...
use IO::Handle;
*STDOUT->autoflush(1);
This ends up far clearer than either example, and the idiom even extends easily to all file handles, lexical or otherwise.EDIT: That being said,
system("sleep 0.02") == 0 or last
is even worse. There is no need to go out to a shell or even an external program for that. use Time::HiRes;
...
sleep(0.02);
...
Not only will that work on far more systems, it will use less resources and is available to all perl's since 5.7.3 (development release from March 2002, first in stable release from July 2002). use Time::HiRes qw/sleep/;http://www.thregr.org/~wavexx/software/trend/
It's already been used for all kind of stuff (https://projects.ardrone.org/boards/1/topics/show/491, ECG, etc).
As the script from the OP, this is a tool to plot STDIN. This one has been refined far more, so it's trivial to use and very powerful.
:-)