How about something like this? I'm returning just the second element of the
resulting list of using split() on $_.
This shortcut for getting just one element of a list can be used on any
function that returns a list. Naturally this is not the most efficient method,
so your mileage may vary.
Andrej Kastrin am Dienstag, 27. Dezember 2005 10.41:
> Hi all,
>
> is there any simple way to read a column of a file into array; e.g. read
> second column
> a b h
> e r z
> u e u
>
> and write it to @array=(b,r,e).
>
> Cheers, Andrej
There are several ways; which is the best depends from the data
On Dec 27, 2005, at 10:41, Andrej Kastrin wrote:
is there any simple way to read a column of a file into array; e.g.
read second column
a b h
e r z
u e u
and write it to @array=(b,r,e).
Sure, for instance:
my @column = ();
while (<>) {
my ($field) = (split)[1]; # extract 2n