Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Winamp random m3u

by OzzyOsbourne (Chaplain)
on Mar 08, 2002 at 15:23 UTC ( #150340=sourcecode: print w/replies, xml ) Need Help??
Category: Audio Related Programs
Author/Contact Info OzzyOsbourne
Description: Creates a random playlist of the number of songs that you input. Edit a the $dir1 and $out vars.
# Generates a Random playlist of the length you specify...

use strict;
use File::Find;
my ($dir1, $input, @array);
find(\&wanted, $dir1);

#----------Sub Routines below this line---------------

sub prep {
    print "Enter the number of songs:";
    chomp ($input=<STDIN>);

sub wanted {
    if (/mp3$/){
        push @array, "$File::Find::name\n";

sub outout{
    my $out="$dir1/upload/randlist.m3u";
    open OUT, ">$out" or die "Cannot open $out for write :$!";
    for (1..$input){
        my $number=int(rand $#array);
        my $result=splice @array, $number,1;
        print OUT "$result";
    close $out;
Replies are listed 'Best First'.
Re: Winamp random m3u
by thraxil (Prior) on Mar 08, 2002 at 20:31 UTC

    first of all, i'd avoid using global variables (yeah, it's only a small script, but it should be habit).

    second, you can rewrite the:



    $result =~ s{/}{\\}g;

    to eliminate LTS.

    anders pearson

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://150340]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (15)
As of 2016-10-27 18:57 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (369 votes). Check out past polls.