Thank you Jim. That got me over that hurdel! Any advice on how to maintain the order of elements in the @header array and print the value to the right of the "=" sign for each dataset, and if there is a value in the dataset that doesn't match the element in the @header simply leave the value blank?
so the output looks like: Thanks again for all your help. Chris >csno,rfpi,vrp0,vrp1,trl,repl,repl_d1,rrl,row[1],rfpc0,rfpc1,row[4],line,row[15],tti 1,1,3423000,3423000,1700000,100,100,20,yes,0,0,,,, 1,2,3423000,3423000,1700000,100,100,,,0,0,,,, 1,3,3423000,3423000,1700000,100,100,20,,,,,,, 2,1,3423000,3423000,1700000,100,100,20,,0,0,,,, 2,2,3423000,3423000,1700000,100,100,20,,,,,,, updated script #!/usr/bin/perl use warnings; use strict; use Data::Dumper; my %seen; my @header; my @data; my $setref = {}; push(@data,$setref); my %headers; my $delim = ","; while(<DATA>) { chomp; if(/(.*)=(.*)/) { $seen{$1}++; $setref->{$1} = $2; $headers{$1}++; if ($seen{$1} == 1) { push(@header,$1); } } elsif(/^\s*$/) { $setref = {}; push(@data,$setref); } } print join($delim,@header),"\n"; print "Field counts:\n\n"; for my $key ( @header ) { printf(" %6s %3d\n", $key,$headers{$key} ); } __DATA__ >csno=1 rfpi=1 vrp0=3423000 vrp1=3423000 trl=1700000 repl=100 repl_d1=100 rrl=20 row[1]=yes rfpc0=0 rfpc1=0 >csno=1 rfpi=2 vrp0=3423000 vrp1=3423000 trl=1700000 repl=100 repl_d1=100 row[4]=no rrl=20 rfpc0=0 rfpc1=0 >csno=1 rfpi=3 vrp0=3423000 vrp1=3423000 trl=1700000 repl=100 repl_d1=100 rrl=20 rfpc0=0 rfpc1=0 >csno=2 rfpi=1 vrp0=3423000 vrp1=3423000 trl=1700000 repl=100 repl_d1=100 rrl=20 line=yes rfpc0=0 rfpc1=0 >csno=2 rfpi=2 vrp0=3423000 vrp1=3423000 trl=1700000 repl=100 repl_d1=100 rrl=20 rfpc0=0 line=value row[15]= tti=1 rfpc1=0 -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/