my($path) = "/home/jstorms/public_html/images/";
my(@files) = get_jpg_from_dir($path);

sub get_jpg_from_dir {
        my($path) = $_[0];
        opendir(DIR,"$path");
        my($filename,@jpeg);
        $filename = readdir(DIR);
        while($filename ne "") {

                if( substr($filename,length($filename)-4,4) eq ".jpg" ||
                    substr($filename,length($filename)-5,5) eq ".jpeg" ) {
                        push(@jpeg,$filename);
                } #endif
                $filename = readdir(DIR);
        } #end while
        closedir(DIR);
        return(@jpeg);
} #end get_jpg_from_dir

---
[EMAIL PROTECTED] (Galactic Hero)
Diplomacy: The art of saying good doggie
while searching for a big rock.

> -----Original Message-----
> From: Evan McNabb [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, June 07, 2001 11:17 AM
> To: [EMAIL PROTECTED]
> Subject: directory listing to array
>
>
>
> I've been working on a little script for a while but I can't seem to get
> this part working. What I want to do is list all of the *.jpg files in a
> directory (ls *.jpg) and then have an array with each filename as elements
> of that array. Its probably easy but I just can't get it right
> yet... :-)
> Thanks for the help.
>
> -Evan
>
> ------------------------------------
>   Evan McNabb     [EMAIL PROTECTED]
>     http://www.mcnabbs.org/evan
> ------------------------------------

Reply via email to