develooper Front page | perl.beginners | Postings from March 2002

RE: how to randomly choose mp3 from dir, print mp3_filename for e mailing to a list]

Thread Next
From:
K Clark
Date:
March 22, 2002 06:18
Subject:
RE: how to randomly choose mp3 from dir, print mp3_filename for e mailing to a list]
Message ID:
20020322141422.GE15918@quantifier.org
Here's what i have, and here's the problem. and here's what i 'think' i
have to learn/do to fix it:

#/usr/bin/perl -w
use strict;
#
# script to randomly choose a song
# and embed html with a link to it
#
my @mp3 = glob("/www/mp3/*.mp3");
#
# put while statement
my $mp3 =~ s#.*/##;

srand;
print "http://www.quantifier.org/mp3" . "$mp3[rand(@mp3)]";

# end

this returns 

[ken:bin](09:04am)$ perl randomsong.pl 
http://www.quantifier.org/mp3/www/mp3/Hooverphonic vs Sneaker Pimps
- Shake the Underground Disease (Puppeteer Remix).mp3

so i get my random song, but i'm not trimming off the directory pathname
of /www/mp3. so i see something in 'learning perl' about globs, and
using a while statement. i can't figure out how to add that while still
declaring my $mp3.

hints?

ken



Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About