in reply to ignore some delimiters while using split

It's easier to just extract the bits you need:

while( <FILE> ) { my( $x, $y, $z ) = m[(\w)\s(\w)\s(\w)\s*$]; print if $x eq $y and $y eq $z; }

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
RIP an inspiration; A true Folk's Guy

Replies are listed 'Best First'.
Re^2: ignore some delimiters while using split
by MajingaZ (Beadle) on Aug 13, 2010 at 01:33 UTC
    print if (/([a-z])\s+\1\s+\1\s*\z/);

    will let you do your checks within the regex.

      And
          print if m{ (whatever) (?: \s+ \1){$n} \s* \Z }xms;
      generalizes to any n.

      >perl -wMstrict -le "my @lines = ( 'foo A A A', 'foo bar A B A', 'foo bar baz A A A' ); my $n = 3; $n -= 1; for my $line (@lines) { print qq{'$line'} if $line =~ m{ \b ([[:alpha:]]) (?: \s+ \1){$n} \s* \Z }xms; } " 'foo A A A' 'foo bar baz A A A'