use strict; use warnings; my $string = '99999999999999999999999999'; my $string2 = '9-999-999-999-999-999-999-999-9999'; # see Note 1 below if ( $string =~ /^(\d)(\1|-)+$/ ) { print "\$string might be a phone number: $string \n"; } else { print "$string is NOK \n"; } if ( $string2 =~ /^(\d)(\1|-)+$/ ) { print "\$string2 might be a phone number: $string2 \n"; } else { print "$string2 is NOK \n"; } print "stiller's snippet: \n"; my $num = 999999999; print sprintf("%f\n",$num); print sprintf("%d\n",$num); #### $string might be a phone number: 99999999999999999999999999 # see Note 2 $string2 might be a phone number: 9-999-999-999-999-999-999-999-9999 # also see Note 2 stiller's snippet: 999999999.000000 # a float, as stiller noted, this address's OP's problem, 999999999 # whereas, Perl makes it easy to use this as a string