use File::Find; my @songs; sub eachFile { if (-e $_ && $_ =~ /\.mp3$/) { push @songs, $File::Find::name;} } find (\&eachFile, "/storage/mp3/");