I've done some changes in this subroutine so it looks like this now:
and it seems to work ! Thanks for pointing me to the right directionmy @entries; my $previouskey = ""; open (KOF, "<$konfil") or die "Kan inte \xF6ppna filen $konfil"; open (NYF, ">$nyfil") or die "Kan inte \xF6ppna filen $nyfil"; flock (NYF,2) or die $!; my $offset = 0; while(<KOF>) { chomp; $value =~ s/^\s*(\S*)\s+$/$1/; if ($key =~ /^(.*)(\d+)$/) { ##### #### #### $key = $1; # # # # # # $entries[$2]{$key} = $value; ##### # # # # next; # # # # # # } # # #### #### unless ($key eq $previouskey || $previouskey eq "") { $offset = 0; } $previouskey = $key; $entries[$offset]{$key} = $value; $offset++; } my @sorted = sort { $a->{'NYTT'} <=> $b->{'NYTT'} } @entries; my $pers =0; foreach my $e (@sorted) { print NYF ($e->{'UID'}, "|", $e->{'FNA'}, "|", $e->{'ENA'}, "|", $ +e->{'PRE'}, "|", $e->{'NYTT'}, "|", $e->{"PRI"}, "|", $e->{"FOR"}, "| +", $e->{"CMG"}, "|", $e->{"MEX"}, "\n") if( $e->{"UID"} ne "" || $e-> +{"FNA"} ne "" || $e->{"ENA"} ne ""); $pers++ if ($e->{"UID"} ne ""); } close KOF; close NYF;
In reply to Re^4: Manipulating data structure
by SerZKO
in thread Manipulating data structure
by SerZKO
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |