if ( my($n1,$n2,$n3,$n4) = string =~ {\A($number) x ($number) x ($number)/($number)\z} and $n1 == $n2 ) { valid format and square}