# begin cheap non portable hack

$list = `/bin/ls -1 *.jpg`;
@array = split(/\n/, $list);

# end cheap non portable hack

# try this a little cleaner

opendir(DIR, ".");
@dir_entries = readdir(DIR);
closedir(DIR);

foreach (@dir_entries)
{
   next if(!/\.jpg/);
   push(@arr, $_);
}

#end attempt at decent code

Probably not the best way. I'm still a newbie hack somedays myself. But this
should work :)

-=- 
G. Andrew Nelson
Release Engineer
Storigen Systems, Inc.
650 Suffolk Street
Lowell MA 01854
+1 978 323 4454 x271


-----Original Message-----
From: Evan McNabb [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 07, 2001 12:17 PM
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