1 | use Coro; |
1 | use Coro; |
2 | use Coro::Semaphore; |
2 | use Coro::Semaphore; |
3 | use Coro::Event; |
3 | use Coro::EV; |
4 | use Coro::Socket; |
4 | use Coro::Socket; |
5 | use Coro::Signal; |
5 | use Coro::Signal; |
|
|
6 | use Coro::AIO (); |
6 | |
7 | |
7 | use HTTP::Date; |
8 | use HTTP::Date; |
8 | use POSIX (); |
9 | use POSIX (); |
9 | |
10 | |
10 | use Compress::Zlib (); |
11 | use Compress::Zlib (); |
… | |
… | |
22 | our $errorlog; |
23 | our $errorlog; |
23 | |
24 | |
24 | our $NOW; |
25 | our $NOW; |
25 | our $HTTP_NOW; |
26 | our $HTTP_NOW; |
26 | |
27 | |
27 | Event->timer(interval => 1, hard => 1, cb => sub { |
28 | our $ERROR_LOG; |
|
|
29 | our $ACCESS_LOG; |
|
|
30 | |
|
|
31 | our $update_time = EV::periodic 0, 1, undef, sub { |
28 | $NOW = time; |
32 | $NOW = time; |
29 | $HTTP_NOW = time2str $NOW; |
33 | $HTTP_NOW = time2str $NOW; |
30 | })->now; |
34 | }; |
|
|
35 | $update_time->invoke; |
31 | |
36 | |
32 | if ($ERROR_LOG) { |
37 | if ($ERROR_LOG) { |
33 | use IO::Handle; |
38 | use IO::Handle; |
34 | open $errorlog, ">>$ERROR_LOG" |
39 | open $errorlog, ">>$ERROR_LOG" |
35 | or die "$ERROR_LOG: $!"; |
40 | or die "$ERROR_LOG: $!"; |
… | |
… | |
55 | our $httpevent = new Coro::Signal; |
60 | our $httpevent = new Coro::Signal; |
56 | |
61 | |
57 | our $queue_file = new transferqueue $MAX_TRANSFERS; |
62 | our $queue_file = new transferqueue $MAX_TRANSFERS; |
58 | our $queue_index = new transferqueue 10; |
63 | our $queue_index = new transferqueue 10; |
59 | |
64 | |
60 | our $tbf_top = new tbf rate => 100000; |
65 | our $tbf_top = new tbf rate => $TBF_RATE || 100000; |
61 | |
66 | |
62 | my $unused_bytes = 0; |
67 | my $unused_bytes = 0; |
63 | my $unused_last = time; |
68 | my $unused_last = time; |
64 | |
69 | |
65 | sub unused_bandwidth { |
70 | sub unused_bandwidth { |
… | |
… | |
78 | # one "execution thread" |
83 | # one "execution thread" |
79 | sub handler { |
84 | sub handler { |
80 | while () { |
85 | while () { |
81 | if (@newcons) { |
86 | if (@newcons) { |
82 | eval { |
87 | eval { |
83 | conn->new(@{pop @newcons})->handle; |
88 | conn->new (@{pop @newcons})->handle; |
84 | }; |
89 | }; |
85 | slog 1, "$@" if $@ && !ref $@; |
90 | slog 1, "$@" if $@ && !ref $@; |
86 | |
91 | |
87 | $httpevent->broadcast; # only for testing, but doesn't matter much |
92 | $httpevent->broadcast; # only for testing, but doesn't matter much |
88 | |
93 | |
… | |
… | |
110 | if (@pool) { |
115 | if (@pool) { |
111 | (pop @pool)->ready; |
116 | (pop @pool)->ready; |
112 | } else { |
117 | } else { |
113 | async \&handler; |
118 | async \&handler; |
114 | } |
119 | } |
115 | |
|
|
116 | } |
120 | } |
117 | }; |
121 | }; |
118 | } |
122 | } |
119 | |
123 | |
120 | my $http_port = new Coro::Socket |
124 | my $http_port = new Coro::Socket |
121 | LocalAddr => $SERVER_HOST, |
125 | LocalAddr => $SERVER_HOST, |
122 | LocalPort => $SERVER_PORT, |
126 | LocalPort => $SERVER_PORT, |
123 | ReuseAddr => 1, |
127 | ReuseAddr => 1, |
124 | Listen => 50, |
128 | Listen => 50, |
125 | or die "unable to start server"; |
129 | or die "unable to start server"; |
126 | |
130 | |
127 | listen_on $http_port; |
131 | listen_on $http_port; |
128 | |
132 | |
129 | if ($SERVER_PORT2) { |
133 | if ($SERVER_PORT2) { |
130 | my $http_port = new Coro::Socket |
134 | my $http_port = new Coro::Socket |
131 | LocalAddr => $SERVER_HOST, |
135 | LocalAddr => $SERVER_HOST, |
132 | LocalPort => $SERVER_PORT2, |
136 | LocalPort => $SERVER_PORT2, |
133 | ReuseAddr => 1, |
137 | ReuseAddr => 1, |
134 | Listen => 50, |
138 | Listen => 50, |
135 | or die "unable to start server"; |
139 | or die "unable to start server"; |
136 | |
140 | |
137 | listen_on $http_port; |
141 | listen_on $http_port; |
138 | } |
142 | } |
139 | |
143 | |
140 | package conn; |
144 | package conn; |
|
|
145 | |
|
|
146 | use strict; |
|
|
147 | use bytes; |
141 | |
148 | |
142 | use Socket; |
149 | use Socket; |
143 | use HTTP::Date; |
150 | use HTTP::Date; |
144 | use Convert::Scalar 'weaken'; |
151 | use Convert::Scalar 'weaken'; |
145 | use Linux::AIO; |
152 | use IO::AIO; |
146 | |
153 | |
147 | Linux::AIO::min_parallel $::AIO_PARALLEL; |
154 | IO::AIO::min_parallel $::AIO_PARALLEL; |
148 | |
155 | |
149 | Event->io(fd => Linux::AIO::poll_fileno, |
156 | our $AIO_WATCHER = EV::io IO::AIO::poll_fileno, EV::READ, \&IO::AIO::poll_cb; |
150 | poll => 'r', async => 1, |
|
|
151 | cb => \&Linux::AIO::poll_cb); |
|
|
152 | |
157 | |
153 | our %conn; # $conn{ip}{self} => connobj |
158 | our %conn; # $conn{ip}{self} => connobj |
154 | our %uri; # $uri{ip}{uri}{self} |
159 | our %uri; # $uri{ip}{uri}{self} |
155 | our %blocked; |
160 | our %blocked; |
156 | our %mimetype; |
161 | our %mimetype; |
157 | |
162 | |
158 | sub read_mimetypes { |
163 | sub read_mimetypes { |
159 | local *M; |
|
|
160 | if (open M, "<mime_types") { |
164 | if (open my $fh, "<mime_types") { |
161 | while (<M>) { |
165 | while (<$fh>) { |
162 | if (/^([^#]\S+)\t+(\S+)$/) { |
166 | if (/^([^#]\S+)\t+(\S+)$/) { |
163 | $mimetype{lc $1} = $2; |
167 | $mimetype{lc $1} = $2; |
164 | } |
168 | } |
165 | } |
169 | } |
166 | } else { |
170 | } else { |
… | |
… | |
174 | my $class = shift; |
178 | my $class = shift; |
175 | my $fh = shift; |
179 | my $fh = shift; |
176 | my $peername = shift; |
180 | my $peername = shift; |
177 | my $self = bless { fh => $fh }, $class; |
181 | my $self = bless { fh => $fh }, $class; |
178 | my (undef, $iaddr) = unpack_sockaddr_in $peername |
182 | my (undef, $iaddr) = unpack_sockaddr_in $peername |
179 | or $self->err(500, "unable to decode peername"); |
183 | or $self->err (500, "unable to decode peername"); |
180 | |
184 | |
181 | $self->{remote_addr} = |
185 | $self->{remote_addr} = |
182 | $self->{remote_id} = inet_ntoa $iaddr; |
186 | $self->{remote_id} = inet_ntoa $iaddr; |
183 | |
187 | |
184 | $self->{time} = $::NOW; |
188 | $self->{time} = $::NOW; |
185 | |
189 | |
186 | weaken ($Coro::current->{conn} = $self); |
190 | weaken ($Coro::current->{conn} = $self); |
187 | |
191 | |
188 | $::conns++; |
192 | ++$::conns; |
189 | $::maxconns = $::conns if $::conns > $::maxconns; |
193 | $::maxconns = $::conns if $::conns > $::maxconns; |
190 | |
194 | |
191 | $self; |
195 | $self |
192 | } |
196 | } |
193 | |
197 | |
194 | sub DESTROY { |
198 | sub DESTROY { |
195 | #my $self = shift; |
199 | my $self = shift; |
|
|
200 | |
196 | $::conns--; |
201 | --$::conns; |
197 | } |
202 | } |
|
|
203 | |
|
|
204 | sub prune_cache { |
|
|
205 | my $hash = $_[0]; |
|
|
206 | |
|
|
207 | for (keys %$hash) { |
|
|
208 | if (ref $hash->{$_} eq HASH::) { |
|
|
209 | prune_cache($hash->{$_}); |
|
|
210 | unless (scalar keys %{$hash->{$_}}) { |
|
|
211 | delete $hash->{$_}; |
|
|
212 | } |
|
|
213 | } |
|
|
214 | } |
|
|
215 | } |
|
|
216 | |
|
|
217 | sub prune_caches { |
|
|
218 | prune_cache \%conn; |
|
|
219 | prune_cache \%uri; |
|
|
220 | |
|
|
221 | for (keys %blocked) { |
|
|
222 | delete $blocked{$_} unless $blocked{$_}[0] > $::NOW; |
|
|
223 | } |
|
|
224 | } |
|
|
225 | |
|
|
226 | our $PRUNE_WATCHER = EV::timer 60, 60, \&prune_caches; |
198 | |
227 | |
199 | sub slog { |
228 | sub slog { |
200 | my $self = shift; |
229 | my $self = shift; |
201 | main::slog($_[0], "$self->{remote_id}> $_[1]"); |
230 | main::slog($_[0], "$self->{remote_id}> $_[1]"); |
202 | } |
231 | } |
… | |
… | |
263 | $hdr->{"Content-Type"} = "text/plain"; |
292 | $hdr->{"Content-Type"} = "text/plain"; |
264 | $hdr->{"Content-Length"} = length $content; |
293 | $hdr->{"Content-Length"} = length $content; |
265 | } |
294 | } |
266 | $hdr->{"Connection"} = "close"; |
295 | $hdr->{"Connection"} = "close"; |
267 | |
296 | |
268 | $self->response($code, $msg, $hdr, $content); |
297 | $self->response ($code, $msg, $hdr, $content); |
269 | |
298 | |
270 | die bless {}, err::; |
299 | die bless {}, err:: |
271 | } |
300 | } |
272 | |
301 | |
273 | sub handle { |
302 | sub handle { |
274 | my $self = shift; |
303 | my $self = shift; |
275 | my $fh = $self->{fh}; |
304 | my $fh = $self->{fh}; |
276 | |
305 | |
277 | my $host; |
306 | my $host; |
278 | |
307 | |
279 | $fh->timeout($::REQ_TIMEOUT); |
308 | $fh->timeout($::REQ_TIMEOUT); |
280 | while() { |
309 | while () { |
281 | $self->{reqs}++; |
310 | $self->{reqs}++; |
282 | |
311 | |
283 | # read request and parse first line |
312 | # read request and parse first line |
284 | my $req = $fh->readline("\015\012\015\012"); |
313 | my $req = $fh->readline("\015\012\015\012"); |
285 | |
314 | |
… | |
… | |
394 | # uri => path mapping |
423 | # uri => path mapping |
395 | sub map_uri { |
424 | sub map_uri { |
396 | my $self = shift; |
425 | my $self = shift; |
397 | my $host = $self->{server_name}; |
426 | my $host = $self->{server_name}; |
398 | my $uri = $self->{uri}; |
427 | my $uri = $self->{uri}; |
|
|
428 | |
|
|
429 | $host =~ /[\/\\]/ |
|
|
430 | and $self->err(400, "bad request"); |
399 | |
431 | |
400 | # some massaging, also makes it more secure |
432 | # some massaging, also makes it more secure |
401 | $uri =~ s/%([0-9a-fA-F][0-9a-fA-F])/chr hex $1/ge; |
433 | $uri =~ s/%([0-9a-fA-F][0-9a-fA-F])/chr hex $1/ge; |
402 | $uri =~ s%//+%/%g; |
434 | $uri =~ s%//+%/%g; |
403 | $uri =~ s%/\.(?=/|$)%%g; |
435 | $uri =~ s%/\.(?=/|$)%%g; |
… | |
… | |
447 | |
479 | |
448 | if ($self->{name} =~ s%^/internal/([^/]+)%%) { |
480 | if ($self->{name} =~ s%^/internal/([^/]+)%%) { |
449 | if ($::internal{$1}) { |
481 | if ($::internal{$1}) { |
450 | $::internal{$1}->($self); |
482 | $::internal{$1}->($self); |
451 | } else { |
483 | } else { |
452 | $self->err(404, "not found"); |
484 | $self->err (404, "not found"); |
453 | } |
485 | } |
454 | } else { |
486 | } else { |
455 | |
487 | |
456 | stat $path |
488 | stat $path |
457 | or $self->err(404, "not found"); |
489 | or $self->err (404, "not found"); |
458 | |
490 | |
459 | $self->{stat} = [stat _]; |
491 | $self->{stat} = [stat _]; |
460 | |
492 | |
461 | # idiotic netscape sends idiotic headers AGAIN |
493 | # idiotic netscape sends idiotic headers AGAIN |
462 | my $ims = $self->{h}{"if-modified-since"} =~ /^([^;]+)/ |
494 | my $ims = $self->{h}{"if-modified-since"} =~ /^([^;]+)/ |
… | |
… | |
465 | if (-d _ && -r _) { |
497 | if (-d _ && -r _) { |
466 | # directory |
498 | # directory |
467 | if ($path !~ /\/$/) { |
499 | if ($path !~ /\/$/) { |
468 | # create a redirect to get the trailing "/" |
500 | # create a redirect to get the trailing "/" |
469 | # we don't try to avoid the :80 |
501 | # we don't try to avoid the :80 |
470 | $self->err(301, "moved permanently", { Location => "http://".$self->server_hostport."$self->{uri}/" }); |
502 | $self->err (301, "moved permanently", { Location => "http://".$self->server_hostport."$self->{uri}/" }); |
471 | } else { |
503 | } else { |
472 | $ims < $self->{stat}[9] |
504 | $ims < $self->{stat}[9] |
473 | or $self->err(304, "not modified"); |
505 | or $self->err (304, "not modified"); |
474 | |
506 | |
475 | if (-r "$path/index.html") { |
507 | if (-r "$path/index.html") { |
476 | # replace directory "size" by index.html filesize |
508 | # replace directory "size" by index.html filesize |
477 | $self->{stat} = [stat ($self->{path} .= "/index.html")]; |
509 | $self->{stat} = [stat ($self->{path} .= "/index.html")]; |
478 | $self->handle_file($queue_index, $tbf_top); |
510 | $self->handle_file ($queue_index, $tbf_top); |
479 | } else { |
511 | } else { |
480 | $self->handle_dir; |
512 | $self->handle_dir; |
481 | } |
513 | } |
482 | } |
514 | } |
483 | } elsif (-f _ && -r _) { |
515 | } elsif (-f _ && -r _) { |
484 | -x _ and $self->err(403, "forbidden"); |
516 | -x _ and $self->err (403, "forbidden"); |
485 | |
517 | |
486 | if (keys %{$conn{$self->{remote_id}}} > $::MAX_TRANSFERS_IP) { |
518 | if (keys %{$conn{$self->{remote_id}}} > $::MAX_TRANSFERS_IP) { |
487 | my $timeout = $::NOW + 10; |
519 | my $timeout = $::NOW + 10; |
488 | while (keys %{$conn{$self->{remote_id}}} > $::MAX_TRANSFERS_IP) { |
520 | while (keys %{$conn{$self->{remote_id}}} > $::MAX_TRANSFERS_IP) { |
489 | if ($timeout < $::NOW) { |
521 | if ($timeout < $::NOW) { |
… | |
… | |
492 | $httpevent->wait; |
524 | $httpevent->wait; |
493 | } |
525 | } |
494 | } |
526 | } |
495 | } |
527 | } |
496 | |
528 | |
497 | $self->handle_file($queue_file, $tbf_top); |
529 | $self->handle_file ($queue_file, $tbf_top); |
498 | } else { |
530 | } else { |
499 | $self->err(404, "not found"); |
531 | $self->err (404, "not found"); |
500 | } |
532 | } |
501 | } |
533 | } |
502 | } |
534 | } |
503 | |
535 | |
504 | sub handle_dir { |
536 | sub handle_dir { |
505 | my $self = shift; |
537 | my $self = shift; |
506 | my $idx = $self->diridx; |
538 | my $idx = $self->diridx; |
507 | |
539 | |
508 | $self->response(200, "ok", |
540 | $self->response (200, "ok", |
509 | { |
541 | { |
510 | "Content-Type" => "text/html", |
542 | "Content-Type" => "text/html; charset=utf-8", |
511 | "Content-Length" => length $idx, |
543 | "Content-Length" => length $idx, |
512 | "Last-Modified" => time2str ($self->{stat}[9]), |
544 | "Last-Modified" => time2str ($self->{stat}[9]), |
513 | }, |
545 | }, |
514 | $idx); |
546 | $idx); |
515 | } |
547 | } |
516 | |
548 | |
517 | sub handle_file { |
549 | sub handle_file { |
518 | my ($self, $queue, $tbf) = @_; |
550 | my ($self, $queue, $tbf) = @_; |
519 | my $length = $self->{stat}[7]; |
551 | my $length = $self->{stat}[7]; |
520 | my $hdr = { |
552 | my $hdr = { |
521 | "Last-Modified" => time2str ((stat _)[9]), |
553 | "Last-Modified" => time2str ((stat _)[9]), |
|
|
554 | "Accept-Ranges" => "bytes", |
522 | }; |
555 | }; |
523 | |
556 | |
524 | my @code = (200, "ok"); |
557 | my @code = (200, "ok"); |
525 | my ($l, $h); |
558 | my ($l, $h); |
526 | |
559 | |
527 | if ($self->{h}{range} =~ /^bytes=(.*)$/) { |
560 | if ($self->{h}{range} =~ /^bytes=(.*)$/i) { |
528 | for (split /,/, $1) { |
561 | for (split /,/, $1) { |
529 | if (/^-(\d+)$/) { |
562 | if (/^-(\d+)$/) { |
530 | ($l, $h) = ($length - $1, $length - 1); |
563 | ($l, $h) = ($length - $1, $length - 1); |
531 | } elsif (/^(\d+)-(\d*)$/) { |
564 | } elsif (/^(\d+)-(\d*)$/) { |
532 | ($l, $h) = ($1, ($2 ne "" || $2 >= $length) ? $2 : $length - 1); |
565 | ($l, $h) = ($1, ($2 ne "" || $2 >= $length) ? $2 : $length - 1); |
… | |
… | |
536 | } |
569 | } |
537 | goto satisfiable if $l >= 0 && $l < $length && $h >= 0 && $h >= $l; |
570 | goto satisfiable if $l >= 0 && $l < $length && $h >= 0 && $h >= $l; |
538 | } |
571 | } |
539 | $hdr->{"Content-Range"} = "bytes */$length"; |
572 | $hdr->{"Content-Range"} = "bytes */$length"; |
540 | $hdr->{"Content-Length"} = $length; |
573 | $hdr->{"Content-Length"} = $length; |
541 | $self->err(416, "not satisfiable", $hdr, ""); |
574 | $self->err (416, "not satisfiable", $hdr, ""); |
542 | |
575 | |
543 | satisfiable: |
576 | satisfiable: |
544 | # check for segmented downloads |
577 | # check for segmented downloads |
545 | if ($l && $::NO_SEGMENTED) { |
578 | if ($l && $::NO_SEGMENTED) { |
546 | my $timeout = $::NOW + 15; |
579 | my $timeout = $::NOW + 15; |
547 | while (keys %{$uri{$self->{remote_id}}{$self->{uri}}} > 1) { |
580 | while (keys %{$uri{$self->{remote_id}}{$self->{uri}}} > 1) { |
548 | if ($timeout <= $::NOW) { |
581 | if ($timeout <= $::NOW) { |
549 | $self->block($::BLOCKTIME, "segmented downloads are forbidden"); |
582 | $self->block ($::BLOCKTIME, "segmented downloads are forbidden"); |
550 | #$self->err_segmented_download; |
583 | #$self->err_segmented_download; |
551 | } else { |
584 | } else { |
552 | $httpevent->wait; |
585 | $httpevent->wait; |
553 | } |
586 | } |
554 | } |
587 | } |
… | |
… | |
565 | |
598 | |
566 | $self->{path} =~ /\.([^.]+)$/; |
599 | $self->{path} =~ /\.([^.]+)$/; |
567 | $hdr->{"Content-Type"} = $mimetype{lc $1} || "application/octet-stream"; |
600 | $hdr->{"Content-Type"} = $mimetype{lc $1} || "application/octet-stream"; |
568 | $hdr->{"Content-Length"} = $length; |
601 | $hdr->{"Content-Length"} = $length; |
569 | |
602 | |
570 | $self->response(@code, $hdr, ""); |
603 | $self->response (@code, $hdr, ""); |
571 | |
604 | |
572 | if ($self->{method} eq "GET") { |
605 | if ($self->{method} eq "GET") { |
573 | $self->{time} = $::NOW; |
606 | $self->{time} = $::NOW; |
574 | $self->{written} = 0; |
607 | $self->{written} = 0; |
575 | |
608 | |
576 | my $current = $Coro::current; |
|
|
577 | |
|
|
578 | my ($fh, $buf, $r); |
|
|
579 | |
|
|
580 | open $fh, "<", $self->{path} |
609 | open my $fh, "<", $self->{path} |
581 | or die "$self->{path}: late open failure ($!)"; |
610 | or die "$self->{path}: late open failure ($!)"; |
582 | |
611 | |
583 | $h -= $l - 1; |
612 | $h -= $l - 1; |
584 | |
613 | |
585 | if (0) { # !AIO |
|
|
586 | if ($l) { |
|
|
587 | sysseek $fh, $l, 0; |
|
|
588 | } |
|
|
589 | } |
|
|
590 | |
|
|
591 | my $transfer = $queue->start_transfer($h); |
614 | my $transfer = $queue->start_transfer ($h); |
592 | my $locked; |
615 | my $locked; |
593 | my $bufsize = $::WAIT_BUFSIZE; # initial buffer size |
616 | my $bufsize = $::WAIT_BUFSIZE; # initial buffer size |
594 | |
617 | |
595 | while ($h > 0) { |
618 | while ($h > 0) { |
596 | unless ($locked) { |
619 | unless ($locked) { |
597 | if ($locked ||= $transfer->try($::WAIT_INTERVAL)) { |
620 | if ($locked ||= $transfer->try ($::WAIT_INTERVAL)) { |
598 | $bufsize = $::BUFSIZE; |
621 | $bufsize = $::BUFSIZE; |
599 | $self->{time} = $::NOW; |
622 | $self->{time} = $::NOW; |
600 | $self->{written} = 0; |
623 | $self->{written} = 0; |
601 | } |
624 | } |
602 | } |
625 | } |
… | |
… | |
604 | if ($blocked{$self->{remote_id}}) { |
627 | if ($blocked{$self->{remote_id}}) { |
605 | $self->{h}{connection} = "close"; |
628 | $self->{h}{connection} = "close"; |
606 | die bless {}, err::; |
629 | die bless {}, err::; |
607 | } |
630 | } |
608 | |
631 | |
609 | if (0) { # !AIO |
632 | Coro::AIO::aio_read $fh, $l, ($h > $bufsize ? $bufsize : $h), my $buf, 0 |
610 | sysread $fh, $buf, $h > $bufsize ? $bufsize : $h |
|
|
611 | or last; |
633 | or last; |
612 | } else { |
|
|
613 | aio_read($fh, $l, ($h > $bufsize ? $bufsize : $h), |
|
|
614 | $buf, 0, sub { |
|
|
615 | $r = $_[0]; |
|
|
616 | Coro::ready($current); |
|
|
617 | }); |
|
|
618 | &Coro::schedule; |
|
|
619 | last unless $r; |
|
|
620 | } |
|
|
621 | |
634 | |
622 | $tbf->request(length $buf); |
635 | $tbf->request (length $buf); |
623 | my $w = syswrite $self->{fh}, $buf |
636 | my $w = $self->{fh}->syswrite ($buf) |
624 | or last; |
637 | or last; |
625 | $::written += $w; |
638 | $::written += $w; |
626 | $self->{written} += $w; |
639 | $self->{written} += $w; |
627 | $l += $r; |
640 | $l += $w; |
628 | } |
641 | } |
629 | |
642 | |
630 | close $fh; |
643 | close $fh; |
631 | } |
644 | } |
632 | } |
645 | } |
633 | |
646 | |
634 | 1; |
647 | 1 |
|
|
648 | |