use warnings; use strict; use List::Util qw/first/; my %INDEX_PAGE = map {$_=>1} '/','/index.html'; my @HELP_PAGE = map {qr/^\Q$_\E/} '/help.html'; 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 (first {$le=~$_} @HELP_PAGE) { print "$le is a help page\n" } else { print "$le is unknown\n" } } # Output: # /help.html is a help page # /index.html is an index page # /help.html?ri=all is a help page