in reply to reading files and directories
Few extra pointers. Order of $b and $a defines whether dirs or files come first. You also could use -T in there. And use of @array before could be removed. Update: put your dir instead of mine :P.#!/usr/bin/perl use warnings; use strict; my $dir = "/Users/ctp/perlwork"; # read all entries from dir and skip '.' and '..' directories opendir (DIRHANDLE, $dir) or die "can't open $dir: $!"; my @list=grep !/^\.\.?\z/, readdir DIRHANDLE; print "<HTML>\n<HEAD></HEAD>\n<BODY>\n"; # now we sort the list on directory basis foreach my $file (sort {-d "$dir/$b" <=> -d "$dir/$a"} @list) { print "<B>$file</B><BR>\n" if -d "$dir/$file"; print "$file<BR>\n" if -T "$dir/$file"; } closedir (DIRHANDLE); print "</BODY>\n</HTML>\n";
|
|---|