chen li wrote: : I need to read a data file containing 96 records/lines : and each record/line contains several columns : separated by tab. I would like to extract the first : column from each record only and put them into a 12x8 : array. Here is the script I use to do the job but it : seems I have some problems with the loop to build a : 12x8 array(I just get a one-dimenstion array only).
I would do it in two steps. Import the first columns of each line then use Array::Dissect to reform() or dissect() the array into an AoA. use strict; use warnings; use Data::Dumper 'Dumper'; use Array::Dissect 'reform'; my $file = 'in.txt'; open my $fh, '<', $file or die qq(Cannot open "$file": $!); my @array; while ( my $line = <$fh> ) { next if $line =~ /CPM/; push @array, ( split ' ', $line )[0]; } close $fh; @array = reform( 12, @array ); print Dumper [EMAIL PROTECTED]; __END__ HTH, Charles K. Clarkson -- Mobile Homes Specialist Free Market Advocate Web Programmer 254 968-8328 Don't tread on my bandwidth. Trim your posts. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>