in reply to Re^6: String comparison in an array
in thread String comparison in an array

This code looks very strange to me.
if ($key eq $first .. $key eq $last) { $in = 1; push @keys, $key; } elsif ($in && $key eq $last) { push @keys, $key; } else { $in = 0; }
One purpose of the "flip-flop" operator is to elminate the need for a flag like $in! The flip-flop operator maintains such a flag internally that is not immediately apparent (and doesn't need to be).

The "if" statement will evaluate to false until $first is seen and remain true up to and including when $last is seen because the flip-flop operator is maintaining the state information that $first has been seen. You do not need to have such a flag yourself.

if ($key eq $first ... $key eq $last) { push @keys, $key; if ($key eq $last) { # do something to process this record in @keys # assuming that there will be a new record # starting with $first on a subsequent line } }
I suggest this classic thread Flipin good, or a total flop? for further study. There is a ".." and a "..." version.