I'm not seeing the problem, unless it has to do with
that last at the end of the conditional within
the loop that traverses the file. The way your code above
is written, you will only ever get one entry, because the
last breaks out of the while.
Conceptually, it seems you want a list of the lines in
the file that match your criterion, so you definitely
should use a single array to hold them all. The way you've
written things so far, you want to store those lines not as
simple strings (which may or may not be what you should do,
depending on the overall aim) but as hashes. Perl doesn't
directly support multi-dimensional arrays, or arrays
of hashes, but it lets the programmer do it by giving you
the ability to store references to any kind of variable any place
where you can use a scalar.
To figure out what the implications of that are, and how to use
the tools Perl gives you, you're going to need to
consult the documentation I pointed to in my posts above. The
basic idea: arrays hold scalars; references are a special
type of scalar -- you can think of them as arrows that
point to data structures (such as hashes), so what you need to do
when you've got a value that is a reference is to get at the thing
the reference points to; there are a number of ways of doing that,
but here's not the place to duplicate the documentation you
have available to you.
To perform an operation on every element of an array (such as
printing out the elements -- NOTE this won't work as you expect
if the members of the array are references) , you will
almost always want to use foreach.
HTH
Philosophy can be made out of anything. Or less -- Jerry A. Fodor
| [reply] [Watch: Dir/Any] [d/l] [select] |