Do you know where your variables are? | |
PerlMonks |
Re: help manipulating data in an array.by larryp (Deacon) |
on Nov 12, 2004 at 04:48 UTC ( [id://407274]=note: print w/replies, xml ) | Need Help?? |
Try this:
The foreach loop allows you to loop through each element of the array, pull out one element at a time ($line), check it for the pattern, and print the appropriate message. You could add a counter in one or both sections of the conditional block to determine the number of matches/non-matches you get and print this as a summary at the end of the script. ( Beats manually counting up the "Match Found" and "Match Failed" lines in the DOS window. :) ) You're going to want to rethink your regular expression, though. :) Think about what the ^ and $ anchors are do. The way you have it written right now, you will only get a match when the number 9432 is the only text in the line. HTH,
In Section
Seekers of Perl Wisdom
|
|