in reply to noshow by file extension

i wasnt too sure about why you obtained the @dirs, but other than that this seems to work pretty well.
(I would also look into replacing grep...)
opendir(DIR, $directory) || die print "Couldn't open directory"; my @unscont = readdir(DIR); closedir(DIR); ## Sorts and Extracts in one statement(each) my @files = sort grep(/\./, @unscont); my @dirs = sort grep(!/\./, @unscont); ## Removes 1st two elements '.' & '..' @files = @files[2..$#files]; my @noshow = (".py", ".html"); foreach $f (@files) { my $switch = true; foreach $n (@noshow) { if($f =~ /$n$/) { $switch = ''; } } if($switch) { print " <a href=\"./this?func=read&file=$f&dire=$dire\">$f</a><br +>\n"; } }

Replies are listed 'Best First'.
Re:x2 noshow by file extension
by grinder (Bishop) on Jun 03, 2002 at 13:30 UTC
    ## Removes 1st two elements '.' & '..' @files = @files[2..$#files];

    Bad advice. That's a dangerous way of removing those two elements, as merlyn pointed out a while ago, in the thread Is readdir ever deterministic?.


    print@_{sort keys %_},$/if%_=split//,'= & *a?b:e\f/h^h!j+n,o@o;r$s-t%t#u'