in reply to Match 2 same characters

So what you want is a regular expression with a backreference.

my @array = qw( foo bar baz quux xyzzy); my @matched; for my $elem ( @array ) { push @matched, $elem if $elem =~ m/(.)\1/; } print "$_\n" for @matched;

See perlre and search for "backreference" or for "find first doubled" for more explanation.