Simplicidade.com <[EMAIL PROTECTED]> wrote: : Probably this is not better and it's not what you want. : Take it as an alternative ;-) : : It's an Array of Hashes. : It gets the column headers from the first row of __DATA__. : When you have fixed length columns 'unpack' is a good choice. : For this example I'm not using __END__ at the end of __DATA__ : :-) : : ################################################################## : : my (@AoH, @headers); : while (<DATA>) { : my %temp;
Define just before you use it or on the first use. Not at the top. Avoid variables named "temp". : my @temp = unpack("A24 A7 A11 A11 A11 A10 A6", $_ ); : $_ =~s/^\s+// foreach @temp; split would probably be easier to maintain. Read up on its special cases in perlfunc. : if ( [EMAIL PROTECTED] ) { : @headers = @temp Why not do the header pass outside the loop? : } else { : $temp{$headers[$_]} = $temp[$_] for ( 0 .. $#temp); A hash slice is neater and faster. This would have been the correct scope for %temp. : push @AoH, \%temp; : } : } my @headers = split ' ', <DATA>; my @tables; while (<DATA>) { my %table; @table{ @headers } = split; push @tables, \%table; } print Dumper [EMAIL PROTECTED]; HTH, Charles K. Clarkson -- Mobile Homes Specialist 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>