in reply to Re: Match 2 same characters
in thread Match 2 same characters

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

Replies are listed 'Best First'.
Re^3: Match 2 same characters
by bichonfrise74 (Vicar) on Mar 20, 2009 at 01:46 UTC
    Hi JohnGG,

    I totally misunderstood the question. Hehehe...