[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Files, directories and droplets



Hi all -

My MacPerl is pretty minimal. I'm trying something that I know a 
million people (give or take a few) have done, and would rather not 
re-invent the wheel. I'm trying to set up a droplet to allow files 
and directories to be dropped simultaneously. I have a few steps left 
and would like the collective to clue me in with the right way 
instead of my way. The program does some minor modifications to some 
web logs, but this part is just handling the files. It should look 
quite a bit like some sections from the MacPerl P&E book.

Here's the code segment:
#	loop through the dropped files/directories
for ($i = 0; $i <= $#ARGV; $i++) {
     #    check if we have a directory
     if (-d $ARGV[$i]) {
         #    store the directory name
         $sDir = $ARGV[$i];
         #    open the directory
         opendir(DIR, $ARGV[$i])
             or die "Can't open $ARGV[$i]\n";
         #    stuff the files into an array
         @files = readdir(DIR);
         #    close the directory
         closedir(DIR);
         #    add the files to the list
         foreach $file (@files) {
             push(@ARGV, "$ARGV[$i]" . ":" . "$file");
         }
     }
     print("$ARGV[$i]\n");
}


And here are the results:
WebServer:WebTen v3.0:logs:WebTen.log
WebServer:WebTen v3.0:logs:archive
WebServer:WebTen v3.0:logs:archive:/
WebServer:WebTen v3.0:logs:archive:WebTen.log-20000122.235908
WebServer:WebTen v3.0:logs:archive:WebTen.log-20000123.235908
WebServer:WebTen v3.0:logs:archive:WebTen.log-20000124.235912

Specific questions:
What's the typical way of handling files and folders in a droplet? 
What is a good way to avoid the 2nd and 3rd line of the output from 
being part of the list?

I have MacPerl, Programming Perl, Learning Perl, Perl Cookbook and a 
couple others on the shelves. If it's easier to reference a book/page 
for details, just point me in the right direction.

Thanks,

Mike Schienle                                 Interactive Visuals, Inc.
mgs@ivsoftware.com                  Remote Sensing and Image Processing
http://www.ivsoftware.com/         Analysis and Application Development

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org