The pattern you need is
my $last; while (defined($_ = next())) { if (!defined($last) || different($_, $last)) { new_group(); $last = $_; } else { same_group(); } }
Replace next, different, new_group and same_group with something appropriate to your problem. Some problems require more than one $last.
In reply to Re: Do Something Until a Variable's Value Changes
by ikegami
in thread Do Something Until a Variable's Value Changes
by de2425
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |