Not necessarily with Perl, though...
My current problem is: when redirecting output to a file, the file is apparently written only by the end of the process... I can't track its progress with something such as tail! :-|
I tried using tee
, Perl, etc... it seems of no avail...
My purpose is a simple one:
mplayer *.mp3 -shuffle | grep Playing >> .now_playing
You can easily tell where this is going... I want to be able to see the music now playing by looking at the last line in the file :-)
use IO::File;
$now = IO::File->new(">>.now");
$now->autoflush(1);
open( MP , "mplayer *.mp3 -shuffle 2>/dev/null |");
while(<MP>)
{
if(/Playing/)
{
print NOW $_;
}
};
Re:How about something like this
cog on 2004-09-03T13:25:58
With some minor twitching (print $now), it works:-) Thanks :-) Re:How about something like this
link on 2004-09-03T13:28:36
Actually that doesn't work but this does( must learn to test before posting)
use IO::File;
open(NOW,">>.now");
autoflush NOW 1;
open( MP , "mplayer *.mp3 -shuffle 2>/dev/null |");
while(<MP>)
{
if(/Playing/)
{
print NOW $_;
}
}