#!/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); }