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:
while ( my $blah = <FILE> ) { if (my ($filename) = ($blah =~/(\w+\.pl)/i) ) { print "$filename was found.\n"; } else { print "no match.\n"; } }
HTH
perl -e 'print "How sweet does a rose smell? "; chomp ($n = <STDIN>); +$rose = "smells sweet to degree $n"; *other_name = *rose; print "$oth +er_name\n"'
In reply to Re: pattern matching -- feeling stoopit
by arturo
in thread pattern matching -- feeling stoopit
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |