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