sleep $playtime;
Here's a very quick rewrite. It's untested, but it's a little nicer, in my opinion.
#!/usr/bin/perl -w use strict; close STDOUT; open(LIST, 'playlist.txt') or die "Can't open playlist: $!"; my @playlist = <LIST>; close LIST; while (@playlist) { my $pos = rand @playlist; my $filename = playlist[$pos]; system("/usr/local/bin/ogg123", '-d', 'oss', 'q', $filename, '&'); sleep 2; foreach (`ps -U root --format pid fname`) { next unless /ogg123/; open(PID, '>player.pid') or warn "Can't log pid ($_): $!"; print PID $_; close PID; last; } open(PLAYING, ">nowplaying.txt") or warn "Can't log filename $file +name: $!"; print PLAYING $filename; close PLAYING; splice @playlist, $pos, 1; my $playtime; foreach (`ogginfo $filename`) next unless /length=(.+)$/; $playtime = $1; last; } sleep $playtime; }
In reply to Re: Re: (Ovid) Re: CGI and Sleep?
by chromatic
in thread CGI and Sleep?
by jellisii
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |