in reply to more with directory contents
Here's how I'd do this. Do note the use of CGI.pm (this beast is now big enough to use it, and the HTML shortcuts will come in handy) as well as strict. I can't stress enough how useful strict is. If you havn't already, please do read all of use strict warnings and diagnostics or die.
The generalization that directories do not contain periods is not particularly true. The true way to test is with the -d file test operator.
Also, CGI::Carp will spew error messages to the browser, like you were looking for.
Anyways, here's how I'd do it:
#!/usr/bin/perl -w use strict; use CGI qw/:standard escape/; use CGI::Carp; my @noshow = (".", "..", __FILE__); my (@directories,@files); opendir(DIR,"./") or die "Couldn't open directory: $!"; for my $entry (sort readdir(DIR)) { next if grep {$_ eq $entry} @noshow; if (-d $entry) { push @directories, $entry; } else { push @files, $entry; } } closedir(DIR); print header, start_html, div({-style=>"border: solid 1 #003366; background: #F1F1F1; text-align: left; padding: 4px; width: 200px;"}, map {a({-style => "font-size: 13px; color: #000000;", -href => "./read_file.cgi?file=".escape($_)},$_) .br} @files), end_html;
perl -pe '"I lo*`+$^X$\"$]!$/"=~m%(.*)%s;$_=$1;y^`+*^e v^#$&V"+@( NO CARRIER'
|
|---|