lemoncube.com Search: (normal)
Articles
Links
News
Projects

Disclaimer

Simple Perl random play script

#!/usr/bin/perl
print "random play\n";

open (F,"ls|");
$x=1;
while (<F>) {
   chomp;
   $track[$x] = "$_";
   $played[$x++] = 0;
}
$num_played=0;
while (1) {
   if (($num_played+1) eq $x) {
      exit;
   }
   do {
      $s = int(rand $x);
   } while ($played[$s] ne 0);
   print "PLAY: $track[$s]\n";
   system "mpg123 \"$track[$s]\"";
   $played[$s]=1;
   $num_played++;
   #sleep 2;

}

pablo , 2003-11-01 04:01:15