Well, what have you tried? And what exactly do you want to store for each
line?
If you want to get a data structure that looks something like line number =>
{Equation => 1, Spec => 2, Timing => 1}, then an ugly way would be

> use strict;
> use warnings;
> use 5.010;
> use Data::Dumper;
>
> my @everything;
> while (<DATA>) {
>     while (/(?<word>\p{L}+)\s+\p{L}+\s+(?<setnumber>[0-9]+)/g) {
>         ${$everything[$. - 1]}->{$+{word}} = $+{setnumber};
>     }
> }
>
> say Dumper \...@everything;
>

Or less ugly:

> my @everything2;
> while (<DATA>) {
>     push @everything2, {/(\p{L}+)\s+\p{L}+\s+([0-9]+)/g};
> }
>

On the other hand, if you just want the numbers,

> my @all_numbers;
> while (<DATA>) {
>     push @all_numbers, [ /([0-9]+)/g ];
> }
>

And if you want them in a string, not an anonymous array,

> my @all_numbers_str;
> while (<DATA>) {
>     push @all_numbers_str, join ', ', /([0-9]+)/g;
> }
>

And the simplest, if you just want one of the numbers,

> my @first_number;
> while (<DATA>) {
>     push @first_number, /Equation Set ([0-9]+)/;
> }
>


If this went over your head, have a look at perlretut[0] and perlreftut[1],
as well as perlre[2] and perlvar[3], for %+ and \p{}.

[0] http://perldoc.perl.org/perlretut.html
[1] http://perldoc.perl.org/perlreftut.html
[2] http://perldoc.perl.org/perlre.html
[3] http://perldoc.perl.org/perlvar.html

Brian.

Reply via email to