laziness, impatience, and hubris | |
PerlMonks |
Re: pattern matching problemby dga (Hermit) |
on Jul 22, 2003 at 17:10 UTC ( [id://276822]=note: print w/replies, xml ) | Need Help?? |
Something like this might work.
In the regular expression I use ()'s to group and capture, then because I used ()'s on the my, it puts a list context onto the assignment and so the RE returns a list of the captured values. In this case the first captured element returned is assigned to $id. I then use $id normally to print out the ID if the RE matched. On a non match $id is undef. I tested with a tiny test case of:
Only the identifier from the first line of the test file is output.
In Section
Seekers of Perl Wisdom
|
|