<untitled> (Perl)
Ревизии: current
#!/usr/bin/perl
use File::Copy;
$path = "../randmages";
opendir(DIR, $path) || die "ops";
while ($filez = readdir(DIR)) {
if ($filez =~ /.*\.jpg/){
push (@files, $filez);
}
}
closedir(DIR);
@files = sort( {lc $a cmp lc $b} @files);
$no_of_images = scalar(@files);
$imgnum = rand($no_of_images);
my $file = "../randmages/$files[$imgnum]";
$size = (stat($file))[7];
print "Content-type: image/jpeg\n";
print "Content-Length: $size\n\n";
open (IMG,"$file");
binmode IMG;
binmode STDOUT;
print <IMG>;
close (IMG);
Комментарии:
Нет