sub score { ## however you decide to assign a score to a filename } sub choose_weighted { ## from that other node } my @audio_files; find( sub { /\.(mp3|wav|wma)$/ && push @audio_files, $File::Find::name }, 'C:\music' ); ## this could go inside the while loop if you needed to recalculate ## relative weights after every song is played: my @weights = map { score($_) } @audio_files; while (1) { my $index = choose_weighted(\@weights); system 'c:\Program Files\Windows Media Player\wmplayer.exe', $audio_files[$index]; print "Another? "; last unless =~ /^y/i }