Using ~ operator to check if a scalar is a string type variable
$x = 111; $y = "This is a string"; print '$x is in string format' if ($x & ~$x); print '$y is in string format' if ($y & ~$y);