Improvement: The brute-force search of the regular expressions is actually not needed; one can just precompile the whole thing as one regular expression. (If you wanted to generalize even more, the same thing could be done for the index pages as well.)
use warnings; use strict; my %INDEX_PAGE = map {$_=>1} '/','/index.html'; my $HELP_PAGE = join '|', map {quotemeta} '/help.html'; $HELP_PAGE = qr/^(?:$HELP_PAGE)/; my @line_entry = ('/help.html','/index.html','/help.html?ri=all'); for my $le (@line_entry) { if (exists $INDEX_PAGE{$le}) { print "$le is an index page\n" } elsif ($le=~$HELP_PAGE) { print "$le is a help page\n" } else { print "$le is unknown\n" } }
In reply to Re^3: Searching for a string within an array using regex
by Anonymous Monk
in thread Searching for a string within an array using regex
by Aquilae
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |