in reply to Improvement on script needed.
Is there a reason that you have to split the lines in the first place? That is, if the last four fileds are significant and always lumped together, you shouldn't waste time splitting and joining those fields.
Also, you shouldn't loop over <DATA> more than once unless absolutely necessary. It can be expensive if the file is large.
my %seen; while (<DATA>) { /^([^\|]+)\|(.*)/; # split at the first "|" my ($key, $value) = ($2,$1); next if $seen{$key}; print "$key: $value\n"; $seen{$key}++; } __DATA__ 34|4|45|56|45 45|34|45|00|23 45|34|45|00|27 34|4|456|56|03 36|4|456|56|03
|
---|
Replies are listed 'Best First'. | |
---|---|
2Re: Improvement on script needed.
by jeffa (Bishop) on Sep 08, 2003 at 13:56 UTC | |
by Anonymous Monk on Sep 08, 2003 at 14:58 UTC | |
by asarih (Hermit) on Sep 08, 2003 at 15:14 UTC | |
Re: Re: Improvement on script needed.
by Anonymous Monk on Sep 08, 2003 at 17:06 UTC | |
by Not_a_Number (Prior) on Sep 08, 2003 at 20:08 UTC |
In Section
Seekers of Perl Wisdom