On 1/12/12 Thu Jan 12, 2012 1:07 PM, "Chris Stinemetz" <chrisstinem...@gmail.com> scribbled:
> Thanks for your advice Jim. > > Although it makes very good sense to me, I am having a little > difficult implementing it. I will have to admit referencing is still a > bit foreign to me. > > I am getting the following error and I am not sure how to fix it. > > Type of arg 1 to push must be array (not reference constructor) at > ./headers.pl line 11, near "$setref)" > Execution of ./headers.pl aborted due to compilation errors. > > > ### SCRIPT ### > > #!/usr/bin/perl > use warnings; > use strict; > > use Data::Dumper; > > my %seen; > my @header; > my @data; > my $setref = {}; > push(\@data,$setref); That should be: push(@data,$setref); > my $delim = ","; > > while(<DATA>) { > chomp; > > if(/(.*)=(.*)/) { > $seen{$1}++; > $setref->{$1} = $2; > > if ($seen{$1} == 1) { > push(@header,$1); > } > } > > elsif(/^\s*$/) { > push(@data,$setref); > print Dumper \@data; > } > } > > print join($delim,@header),"\n"; > > > __DATA__ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/