CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Not Returning Directory List

 



jr
Novice

Mar 10, 2000, 11:22 AM

Post #1 of 2 (577 views)
Not Returning Directory List Can't Post

I'm using an archive system to generate ZIP files of my entire site directory in an archive file, which then is auto-dl'ed to my computer...it works fine, given that it only backups files in the first directory. However, it does not open the sub-directories or archive what is in those directories, though it can SEE the sub-directories...

Is maybe the following code off?
<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


sub GetDirectories()
{
$last_part = split(/\//,$CGIDirectory);
$this_cgi_directory = @_[$last_part-1];

$complete_List = `ls -l $TopDirectory`;
@entryArr = split(/\n/,$complete_List);
$i = 0;
foreach $_ (@entryArr)
{
if((substr($_,0,1) ne "l") && (substr($_,0,1) ne "t"))# no symbolic links and not the total line
{
$number_of_columns = split(/ /,$_);
if((@_[$number_of_columns-1] ne "Archive_It") && (@_[$number_of_columns-1] ne $this_cgi_directory))
{
if($query->param(@_[$number_of_columns-1]) eq "T")
{
@dirArr[$i] = @_[$number_of_columns-1];
#print "@dirArr[$i]<br>";
$i++;
}

}
}
}

}
</pre><HR></BLOCKQUOTE>


summer
Deleted

Mar 13, 2000, 1:10 PM

Post #2 of 2 (577 views)
Re: Not Returning Directory List [In reply to] Can't Post

jr,

I'd recommend using the File::Find module:

###########

use File::Find ;

# Get the root of the tree you want to walk.

find( \&wanted, $TopDirectory ) ;

sub wanted {
return if -d ; # Ignore dirs
# put other returns here to ignore anything else, e.g. symbolic links etc.
print "$_\n" ; # Change this to the action to perform.
}

#########

That's it. Let the module take care of the directory handling for you; you just need to deal with individual files.

Of course if you have tar and gzip you could
execute this from your shell:

# tar cvfz myarchive.tar.gz /path/to/files

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives