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 2nd field, see below
        push @column, $field;     # push $field onto the end of @column
    }

The way to extract the field in a given row depends on the conventions used in the file, I used split for the sake of the example.

-- fxn


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to