"Matt Garrish" <> wrote in message
news:tvgQc.28984$ ...
>
> "Ken Sington" <ken_sington@nospam_abcdefg.com> wrote in message
> news:vJmdnbh-yuSIGIzcRVn-...
> > this is starting to bother me:
> >
> > if (
> > $req =~ /\.html$/ ||
> > $req =~ /\.pl$/ ||
> > $req =~ /\.shtml$/ ||
> > $req =~ /\.txt$/ ||
> > $req =~ /\.cgi$/ ||
> > $req =~ /\.cgi\?/ ||
> > $req =~ /\/\?/ ||
> > $req =~ /\/$/
> > ) {
> > $countPage++;
> > }
> >
> >
> > there's got to be a better way.
>
> I see three different clusters that just can't be merged. The following
will
> decrease the readability immensely, but will compact the code if that's
all
> you want:
>
> if ( $req =~ m#(\.(s?html?|pl|cgi|txt)$)|(/[$?])|(\.(pl|cgi)\?)# ) {
> $countPage++; }
>
Oops! For some reason I thought the $ in the last expression was escaped (I
also should have escaped it in the character class (/[\$?]), so double my
bad!):
if ( $req =~ m#(\.(s?html?|pl|cgi|txt)$)|(/\?)|(\.(pl|cgi)\?)# ) {
$countPage++; }
Matt
|