#SEARCH THROUGH THE CONTENT DIRECTORY AND FIND THE FILES THAT MATCH chdir("$contentdir");#change to the content directory my $stuff = ".";#make it $_ opendir THISDIR, "$stuff";#open the content directory my @submenu = readdir THISDIR;#put the names of the files in an array closedir THISDIR; for (1..2) {shift @submenu;} my @aaa; for (@submenu) { push(@aaa,[split /\_/,$_,3]); } my @final = sort {$a->[2] <=> $b->[2] } @aaa; for (@final) { my $cat=$_->[0]; my $title=$_->[1]; my $rankk=$_->[2]; (my $rank, $tossit) = split (/\./, $rankk,2); #foreach submenu item print it if ($cat=~$main) { $counter++; if ($counter > 1) { print ""; print "$sub2"; print ""; etc., etc. i know this isn't pretty, but it is what it is.