use Fcntl qw(SEEK_SET); use strict; # Calculate Relationships. # - Rely on increment, as it's the easier of the two to calculate. my %decrement; my %increment; # Synonymous with existance. my $start_of_DATA = tell DATA; while () { chomp; my $item = $_; # Note concerning parsing # - This regex requires that a prefix exist. if ($item =~ m{ (\w+) ( (?) { chomp; print; if ($increment{ $decrement{ $_ } }) { print ";$decrement{$_}"; } elsif ($increment{ $increment{ $_ } }) { print ";$increment{$_}"; } print "\n"; } __DATA__ AAA30 BBC5 SHT12H DAL33B BBC49 AAA31 BBC8 BBC3 DAL33A BBC6 SHT12G BBC50