5 ###APPDATE: Tue Sep 18 10:56:07 2007
7 ###APPDESC: grep the first html file name
9 ###APPEXAMPLE: ls | firsthtml
11 #$ARGV[0]="--help" unless(@ARGV);
12 exit 0 unless(system("plhelp",$0,(@ARGV)));
14 my @INDEXS=qw(cs2w_index cover index toc default aaa bbb content first);
15 my @EXTS=qw(htm html shtml txt);
18 return 0 unless($target);
19 foreach my $indexName(@INDEXS) {
20 return 1 if ($target =~ m/\b${indexName}\b[^\/\\]*$/i
);
25 return 0 unless($target);
26 foreach my $extName(@EXTS) {
27 return 1 if ($target =~ m/\.\b$extName\b$/i);
40 push(@indexFiles,$_) if(isIndexFile
($_));
43 # return if (@allFiles<1);
44 # return $allFiles[0] if(@allFiles==1 or @htmlFiles<1);
45 return if(@htmlFiles<1);
46 return $htmlFiles[0] if(@htmlFiles==1 or @indexFiles<1);
47 return $indexFiles[0] if(@indexFiles==1);
50 my $minSlashCount=256;
51 foreach my $filename(@indexFiles) {
52 my $slashCount=$filename =~ tr
/\//\//;
53 if($slashCount<$minSlashCount) {
55 $minSlashCount=$slashCount;
57 return $result if($minSlashCount==0);