in reply to How to increment a sequence number for evert instance of a value?

Ok this is what I came up with....it "looks" right to me. I do a Print " The ID is $rp1 and the Sequence is $invseq\n"; and the ID prints but the sequence has no value. I guess I messed up in the hash? Not really sure what I am doing wrong now.
if ($flag21 == 1) { foreach $num(@number) { if (($num) eq ($rp1)) { $invseq = $seqi{$rp1}; $invseq = $invseq + 1; $seqi{$rp1} .= $invseq; } else { $seqi{$rp1} .= 1; $invseq = $seqi{$rp1}; push @number, $rp1; } } }
I changed the first part to a 3 step add thinking I messed up somewhere there it was originally this (and didn't work)
if ($flag21 == 1) { foreach $num(@number) { if (($num) eq ($rp1)) { $seqi{$rp1} += 1; $invseq = $seqi{$rp1}; } else { snipped the rest off as it was the same

Replies are listed 'Best First'.
Re: Re: How to increment a sequence number for every instance of a value?
by aschroh (Novice) on Jun 26, 2003 at 19:47 UTC
    Ok guys Enlil explained Tomte example in terms even I can understand =P. I got it working correctly now....and it was only 3 lines instead of 20 lol. Thanks to all who responded here and in Chatterbox =)