Forgive me if I've misunderstood what you're trying to do, but the following would yield an array of all the files (and directories) in a given directory:
my $path = 'yourdir/yoursubdir/'; # or whatever
my @filearray;
while (<$path*>) {
s/$path//; # strip off the filepath
push @filearray, $_; # push the filename into the array
}
You can then use the array to generate the form fields on your page. If you wanted to get only files with, for example, extension
.txt, you would use
<$path*.txt>(By the way, if you are new to perl - and I must say I only learnt this stuff a couple of months ago - you may wish to be reassured that the snippet above comes to much the same as
while (my $file = <$path*>) {
$file =~ s/$path//;
push @filearray, $file;
}
... though if you knew that already... well silly me.)
Sorry this is not a comprehensive solution: I hope it's some help.
§
George Sherston
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.