Hi Cody, (I have taken everything you stated and applied it to the code with the best of my abilities). If you should copy this code into a new cgi named viewdir.cgi & then fill in the 2 paths needed you could see it displays all folders in the specified dir and just fails to filter the seclected value"" when selected. I really like the things you've shown me thus far and I hope this complete code below will assist you better with answering my filtering question. Thank you so much for your valued time! Jim tf198@netzero.net
------------------------------------------------------------ #!/usr/bin/perl -w use CGI::Carp qw(fatalsToBrowser); $viewdirpath = "/home/your_site_id/www/folder_chosen_to_view"; $viewdirpath_only = "http://www.your_url.com/folder_chosen_to_view"; $script = "http://www.your_url.com/folder_chosen/viewdir.cgi"; print "Content-type: text/html\n\n"; &view_dir; sub view_dir { opendir DIR, "$viewdirpath"; @$_ = readdir DIR; closedir DIR; $count = 0; foreach $_ ( sort @$_ ) { $fitem_pathname = "$viewdirpath" . "/" . "$_"; if (-e $fitem_pathname && -d $fitem_pathname) { unless ($_ eq ".." || $_ eq ".") {$count++;}}} print "<body bgcolor=\"#ffffff\"text=\"#000000\" link=\"#000000\ vlink +=\"#000000\ alink=\"#000000\>"; print "<b>Folders Listed In Directory - $count</b><br>"; print "<form name=\"sortbyform\" action=\"viewdir.cgi\" method=\"GET\" +>"; print "sort by<br>"; print "<select name=\"sortby\" onChange=\"if (sortbyform.sortby != \'' +) { sortbyform.submit(); }\">"; print "<option value=\"\">Select</option><br><br>"; foreach $sortby (@file = (a..z)) { if ($FORM{'sortby'} eq $sortby) { print "<option value=\"$sortby\" SEL +ECTED>$sortby</option>";} else { print "<option value=\"$sortby\">$sortby</option>";} } print "</select>"; print "</form>"; foreach $_ ( sort @$_ ) { $fitem_pathname = "$viewdirpath" . "/" . "$_"; if (-e $fitem_pathname && -d $fitem_pathname) { unless ($_ eq ".." || $_ eq "." || $_ eq "admin") { if($_ =~ m/^$FORM{'sortbyform'}/i) { print "<br><a href=$viewdirpath_only/$_>$_</a>";}}} } } ------------------------------------------------------------

edited: Mon Jan 27 15:13:20 2003 by jeffa - added code tags


In reply to Re: Re: sorting a text file in PERL using a dropdown form by Anonymous Monk
in thread sorting a text file in PERL using a dropdown form by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.