This may be a typo. strict would have caught it.

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.