waxmop has asked for the wisdom of the Perl Monks concerning the following question:
I need to load in data from a file that looks sort of
like this:
I want to grab every AAA.number and push it into an array like so:AAA.1, AAA.2, AAA.3, AAA.4, AAA.5
But I don't know how to deal with the fact that there could be 1 or 2 AAA codes on each line. Is there a way to write a regular expression that will match a pattern and return a $1 variable over and over again?my @list; while (<INFILE>) { m/(AAA.\d)/; push @list, $1; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: accumulating rex-exp matches in an array
by arturo (Vicar) on Jun 25, 2002 at 18:23 UTC | |
Re: accumulating rex-exp matches in an array
by japhy (Canon) on Jun 25, 2002 at 18:27 UTC | |
Re: accumulating rex-exp matches in an array
by Sifmole (Chaplain) on Jun 25, 2002 at 18:17 UTC | |
Re: accumulating rex-exp matches in an array
by thelenm (Vicar) on Jun 25, 2002 at 18:25 UTC | |
Re: accumulating rex-exp matches in an array
by joshua (Pilgrim) on Jun 25, 2002 at 18:22 UTC | |
Re: accumulating rex-exp matches in an array
by Anonymous Monk on Jun 25, 2002 at 18:23 UTC |
Back to
Seekers of Perl Wisdom