in reply to sorting a text file in PERL using a dropdown form
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..
and the later chomp can be thrown away: just use @file = (a..z);open (INF,"sortby_list.dat"); @file=<INF>; close(INF);
also,
can be replaced withif (-e $fitem_pathname) { if (-d $fitem_pathname) { unless ($_ eq "..") { unless ($_ 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.if (-e $fitem_pathname && -d $fitem_pathname) { unless ($_ eq ".." || $_ eq ".") { $count++; } }
Your regex
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'}]/
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: sorting a text file in PERL using a dropdown form
by Anonymous Monk on Jan 27, 2003 at 14:35 UTC | |
by Cody Pendant (Prior) on Jan 28, 2003 at 02:30 UTC | |
by Anonymous Monk on Jan 28, 2003 at 13:09 UTC |