Live data from Hacker News

Easily plot realtime data (via Perl and GnuPlot)

users.softlab.ntua.gr

11–15 of 15 posts

Re: Easily plot realtime data (via Perl and GnuPlot)

#12
post #4

Line 5 just made me spill my coffee (or I need to drink some more). Since STDOUT is the default filehandle, there is no need to muck around with that anachronism. A simple $| = 1 would suffice. This idiom was once useful for setting autoflush for a filehandle other than STDOUT, but this is not the case here. For a lengthier discussion on this, including the apologies of Randal Schwartz for coming up with it (when adm…

A nicer way to do it that's not as obtuse, since 5.6 is to do 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 w…

just a correction, you need to import the sleep function from Time::HiRes, otherwise it will use the default sleep function and sleep 0 seconds instead.

    use Time::HiRes qw/sleep/;

Re: Easily plot realtime data (via Perl and GnuPlot)

#13
post #10

Got a better one for you: https://github.com/dkogan/feedgnuplot 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.

"This program is originally based on the driveGnuPlots.pl script from Thanassis Tsiodras. It is available from his site at http://users.softlab.ece.ntua.gr/~ttsiod/gnuplotStreaming.ht...

:-)

Re: Easily plot realtime data (via Perl and GnuPlot)

#14
Perl/shell utilities to drive gnuplot come over and over on HN and Reddit. Gnuplot is _slow_. There's a better (and easier) way to deal with realtime data:

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).

Post reply on HN