box-o-sand/web/lib/perl/base.pm

39 lines
641 B
Perl
Raw Normal View History

2011-01-03 21:40:52 +00:00
package base;
use strict;
use warnings;
2011-01-03 21:40:52 +00:00
use nginx;
sub handler {
my $r = shift();
2011-01-03 21:40:52 +00:00
$r->send_http_header("text/plain");
return OK if $r->header_only();
2011-01-03 21:40:52 +00:00
$r->print("Hello There!\n");
$r->rflush();
2011-01-03 21:40:52 +00:00
if (-f $r->filename or -d _) {
$r->print($r->uri, " exists!\n");
} else {
$r->print($r->uri, " does not exist!\n");
}
my $directory = '/home/me/tmp';
# '/home/me/src/LearningPerl/src/web';
my $didopen = opendir(DIR, $directory);
if ($didopen) {
while (my $file = readdir(DIR)) {
$r->print("$file\n");
}
closedir(DIR);
2011-01-03 21:40:52 +00:00
}
}
1;
__END__