I don't know where to start with this one, but some things which are immediately obvious:
- You haven't got a form. You've got a JavaScript onChange statement in a SELECT menu. That's not the same as submitting a form. In fact this menu wouldn't even appear in some browsers, because it's not surrounded by a set of FORM tags
- Huge chunks of this script are missing. Where are your colours supposed to come from in the BODY tag? More importantly, where's the part of your script where the form, if you really had one, gets processed and the %FORM hash created? Where is $viewdirpath coming from? It's set to an empty string, then used a couple of lines later. It seems like it might come from a hidden field in the missing form, or some other form, which makes your script hideously insecure.
- Your code doesn't even run, because there's an extra bracket at the end.
So if you really want help, show us all the code -- this can't be it.
As I can't help you with this, some very basic things:
You don't need a file with every letter in the alphabet it it..
open (INF,"sortby_list.dat");
@file=<INF>;
close(INF);
and the later chomp can be thrown away: just use
@file = (a..z);
also,
if (-e $fitem_pathname) {
if (-d $fitem_pathname) {
unless ($_ eq "..") {
unless ($_ eq ".") {
$count++;
}
}
}
}
can be replaced with
if (-e $fitem_pathname && -d $fitem_pathname) {
unless ($_ eq ".." || $_ eq ".") {
$count++;
}
}
that is, you don't need to nest two statements which both need to be true and so on. Though there are better ways of doing what that code does anyway.
Your regex
if($_ =~ m/^[$FORM{'sortby'}]/
doesn't work. You don't need the brackets, plus, it should be case-insensitive, as we only have lowercase letters in our @file array.
if($_ =~ m/^$FORM{'sortby'}/i)
But I feel guilty even going this far into the Perl because it's pretty much meaningless without the rest of it, and pretty much broken in various other ways.
One final thing? You're not sorting anything. You're filtering a list of directories by first letter.
--
Every bit of code is either naturally related to the problem at hand, or else it's an accidental side effect of the fact that you happened to solve the problem using a digital computer. M-J D
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.