Perl Monk, Perl Meditation | |
PerlMonks |
Re: pattern matching -- feeling stoopitby arturo (Vicar) |
on Oct 02, 2001 at 20:50 UTC ( [id://116188]=note: print w/replies, xml ) | Need Help?? |
What's in grepfile ? The output of your grep ? (which is what, exactly? filename: [ matching line ] ? -- I'll assume that) You need to put capturing parens in the regex for $1 to get set by a successful match. Now, assuming valid filename characters are \w (not quite true, but probably OK in the present context) what you want to match is not just the "pl" but the "." that comes before it and a bunch of word characters before that. And you probably only want the ones that are referenced within form action tags, for that matter, but let's leave that for a future refinement. So the regex you want matches "one or more word ( \w ) characters, followed by a literal ., followed by 'pl'." => /\w+\.pl/ (\w character => one or more => a literal dot => "pl" ). Toss in the parentheses, and make the match case-insensitive (maybe necessary, maybe not), and use some nifty shorthand to put the results of $1 into a variable, and you get:
HTH
In Section
Seekers of Perl Wisdom
|
|