I'm trying to grab information out of a series of files and place each file's data into an array of arrays for use later. Each file has a different number of pieces of information that I need to grab.
I'd like to do this using a foreach loop, iterating through each file, grabbing the data and assigning it to the array of arrays. I've defined an array of regular expressions, one for each file, that successfully grabs the data, however each regexp has a different number of strings to return.
What I'm wondering is how I can determine the number of returns ($1 .. $N) from a regexp, and return them, at run-time. Is there a variable somewhere that stores the number of matches, or do I need to store this myself (not a problem), and if so, is it legal to use code like
foreach ( 1 .. $numMatches ) { print $$numMatches }
to return each match?
Any comments or suggestions would be a great help.
-- Foxcub
In reply to Returning N values from a Regexp by Tanalis
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |