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 format, your requirements, performance tests etc. Here are two ways (not recommended for big data), based on the small amount of information you provide: use strict; use warnings; my @lines=('a b h', 'e r z', 'u e u'); # test input format my @a1= map /.{2}(.)/, @lines; my @a2= map $_->[1], map [split /\s+/, $_], @lines; print join "-", @a1, '/', @a2; # prints: b-r-e-/-b-r-e hth joe -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>