in reply to Re: Perl code to format the text file by inserting tag in blank line
in thread Perl code to format the text file by inserting tag in blank line
"Off by one" is one of the most common errors in programming. I personally would rewrite the code so that it doesn't use indices at all like: foreach my $element (@array){} However a re-write like appears to be outside the scope of the question before us. Perl code like that would use index 0. However there would not be any direct reference to that zero index within the code at all. Creating the kpi array would use "push" instead of explicit indices from 1..n. If the OP creates the kpi array with starting with $kpi[1] that just makes index 0 undef (skips it). I don't see any indication that the OP is aware of: push,pop,shift,unshift.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Perl code to format the text file by inserting tag in blank line
by AnomalousMonk (Archbishop) on Feb 13, 2020 at 06:00 UTC | |
by Marshall (Canon) on Feb 13, 2020 at 06:33 UTC |