Forgot to forward to the list, sorry again

---------- Forwarded message ----------
Date: Fri, 6 Sep 2002 15:19:58 +0530 (IST)
From: Sudarshan Raghavan <[EMAIL PROTECTED]>
To: Fabian Funk <[EMAIL PROTECTED]>
Subject: Re: Reading Directory

On Wed, 4 Sep 2002, Fabian Funk wrote:

> Hi, I'm pretty new to perl. I want to open a Directory with mp3 files an 
> other files. My Poblem is i need only the mp3 files. How can i get only 
> the mp3 files and not other files ?
> 
> I tried:
> 
> while (defined(my $file=readdir(DIR))) {
>       next if $file=~ /^\.\.?$/;
>       next unless /\.[mp3]$/i;

You have to read the filename into $file and matching on $_ (pattern match 
defaults to this). Also this matches for *.m or *.p *.3.

You can do away with the while loop
my @mp3_files = <$your_search_dir/*.mp3>;
perldoc -f glob
perldoc File::Glob
 



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to