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

[MacPerl] AAARG!



The script we've been working on (and thanks for all the help) is great.
I've finally got it working. It's slow as sin.

In fact, it's SO slow, that my web server (WebStar 2.0) sends back an empty
page as the response. Now, I can either send back a page immidiately, and
tell the user to access another page in a few seconds, or I can tweak it.
I'd vie for the later.

This is what I made of the only script that worked with any accuracy for
me, the Droplet:

#!perl
use Mac::Files;

opendir(DIRE, "Web:Webstar:Webpages");
@folders = readdir(DIRE);
close(DIRE);
$warnings = "";
$alarms = "";

foreach $it (@folders) {
	$end = &cool ("Web:Webstar:Webpages","$it");
	if ($end >= 5120000) {$warnings .= "Web:Webstar:Webpages:$it =
$end<br>";}
	elsif ($end >= 4096000) {$alarms .= "Web:Webstar:Webpages:$it =
$end<br>";}
}

opendir(DIRE, "Web:Webstar:Webpages2");
@folders = readdir(DIRE);
close(DIRE);

foreach $it (@folders) {
	$end = &cool ("Web:Webstar:Webpages2","$it");
	if ($end >= 5120000) {$warnings .= "Web:Webstar:Webpages2:$it =
$end<br>";}
	elsif ($end >= 4096000) {$alarms .= "Web:Webstar:Webpages2:$it =
$end<br>";}
}

$ans = "Warnings (Directories over 5mb):<br><br>$warnings<br><br>Alarms
(Directories over 4mb):<br><br>$alarms<br><br>";

$theReply = <<HT_ML;
Content-type:	text/html

<html><head><title>Directory Size Warnings: Clarity
Connect</title></head><body>
<center><font size = "+3">For Clarity Connect Internal Use Only</font></center>
$ans</center></form></body></html>
HT_ML

print $theReply;
print "\n";

sub cool {
	$siz = 0;
	my $a = $_[0];
	my $b = $_[1];
	# print "\n-\n$a:$b\n-\n";
	chdir("$a:$b");
	lstat(":");
	&dodir;
	return "$siz";
}

sub dodir {
    my $dir = shift;
    my @files = ();
    my $item = "";
    my $name = "";

    if (-d _) {
        opendir(DIR, ":");
        @files = readdir(DIR);
        close(DIR);
        unless (@files) {print "$dir - empty folder\n"}
        foreach $item (@files) {
            lstat($item);
            $dir = "" unless $dir;
            $name = "$dir:$item"; #24
            unless (-d _) {$siz += main::get_size($item);next;}
            chdir($item);
            &dodir($name);
            chdir('::');
        }
    }
}

sub get_size {
    my $file = shift;
    my $len = '';
    my $cat = FSpGetCatInfo($file);
    $len = $cat->{ioFlLgLen};
    $len += $cat->{ioFlRLgLen};
    # print "$file has $len bytes\n";
    $len
}

If no one knows how to make this faster, does anyone know how to make a
page that automatically forewards to another page after a specified period
of time?

(I didn't make the first bit a function because I was tired of getting
errors, and I'm kinda tired as it is. It might be faster that way... I
don't know.)

-Seraph



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch