Here is how i would do it (hey, this isn't homework is it?)
use strict;
use CGI qw(:header);
use CGI::Carp qw(fatalsToBrowser);
use File::Find;
use File::Basename;
my $start = 3;
my $end = 40;
my $dir = 'files';
@ARGV = ();
die "start must be less than end" if $start >= $end;
die "no dir $dir here" unless -d $dir;
find sub {
my $numb = (fileparse($_,'.txt'))[0];
return unless $numb =~ /^\d+$/;
push @ARGV, $File::Find::name if $numb >= $start and $numb <= $end;
}, $dir;
die "no .txt files found in $dir" unless @ARGV;
print header;
print while <>;
UPDATE:
I should explain that File::Find works recursively, so any
sub directories in the parent directory that match will be
printed as well. Also, from here it is rather trivial to
use CGI.pm's param() method to accept arguments from the
cgi script. Don't forget to add -T (taint mode) and 'scrub'
these arguments before using them. That i leave as an
excercise. ;)
jeffa
L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.