#!/usr/bin/perl
use Data::Dumper;
open(PLAYLIST,") {
chomp();
push(@songs,$_);
}
my $count = scalar(@songs);
print "We found $count songs\n";
while (scalar(@songs) > 0) {
my $song_num = rand(scalar(@songs));
print "*** Playing $songs[$song_num]\n";
`mpg321 '$songs[$song_num]'`;
splice(@songs,$song_num,1);
}
####
#!/usr/bin/perl
my $song_num;
my @songs;
my $pid;
sub catch_next {
my $signame = shift;
print "Going to next song!\n";
my $count = kill(15,$pid);
}
sub reaper {
$waitedpid = wait;
$SIG{CHLD} = \&reaper;
}
open(PLAYLIST,") {
chomp();
push(@songs,$_);
}
$SIG{INT} = \&catch_next;
$SIG{CHLD} = \&reaper;
my $count = scalar(@songs);
print "We found $count songs\n";
while (scalar(@songs) > 0) {
$song_num = rand(scalar(@songs));
my $song = $songs[$song_num];
splice(@songs,$song_num,1);
print "*** Playing $song\n";
unless ($pid = fork) {
exec("mpg321", "$song");
}
waitpid($pid,0);
}
####
#!/usr/bin/perl
my $song_num;
my @songs;
my $pid;
sub catch_next {
my $signame = shift;
print "Going to next song!\n";
my $count = kill(15,$pid);
}
open(PLAYLIST,") {
chomp();
push(@songs,$_);
}
$SIG{INT} = \&catch_next;
my $count = scalar(@songs);
print "We found $count songs\n";
while (scalar(@songs) > 0) {
$song_num = rand(scalar(@songs));
my $song = $songs[$song_num];
splice(@songs,$song_num,1);
print "*** Playing $song\n";
unless ($pid = fork) {
exec("mpg321", "$song");
}
waitpid($pid,0);
}