#!/usr/bin/perl # Plays a random file from $dir using $player. # I still have not figured a good way to quit other than killing # the perl program and then the player, anybody have some good ideas? # UPDATE: now properly replaces escape characters (old version replaced with space) use strict; my $dir = "/dosc/Music/"; my $player ="mpg123"; my ($i, @music); opendir (DIR, $dir); @music = readdir (DIR); closedir (DIR); foreach (@music) { s/([\s|&|\\|\||(|)|'|_])/\\$1/g; # Add escape characters } srand(); while (1) { $i = @music[int(rand(scalar(@music)))]; system "$player $dir$i"; }