A grep might be a bit simpler. I'm not sure why you push the first element outside of the loop and then have to test for element number inside. It seems to be an un-necessary complication.
use strict; use warnings; my @pets = qw{ gerbil parrot hamster cat poodle goldfish }; my @doubles = grep m{(.)\1}, @pets; print qq{$_\n} for @doubles;
The output
parrot poodle
I hope this is of interest.
Cheers,
JohnGG
In reply to Re^2: Match 2 same characters
by johngg
in thread Match 2 same characters
by paragkalra
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |