Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Please advise what is best way to do this where I want a regular expresssion to check all pages instead of just pagehere.cgi:
if $mypath =~ "mydirectory/dirOne/pagehere.cgi" { print "results here"; } #Now my attempt not working: if $mypath =~ "mydirectory/dirOne/*.cgi" { print "results here"; }
Please advise because I think my reg expression is not correct or I am formatting it wrong?

Replies are listed 'Best First'.
Re: Finding all pages in a path
by ikegami (Patriarch) on Sep 23, 2005 at 14:20 UTC
    if ($mypath =~ m{(?:^|/)mydirectory/dirOne/pagehere\.cgi$}) { print "results here"; } if ($mypath =~ m{(?:^|/)mydirectory/dirOne/[^/]+\.cgi$}) { print "results here"; }

    (?:^|/)mydirectory
    makes sure we don't match
    notmydirectory

    [^/]+
    means "one or more of (not a slash)".