in reply to Re^3: Determining uniqueness in a string.
in thread Determining uniqueness in a string.
Actually, the print statement is probably much more expensive than any of those comparisons.
Anyway, I noodled with the script a bit.
#!/usr/bin/perl use warnings; use strict; while ( <> ) { chomp; (/^\d{10}$/) ? print uniq($_)+0,"\n" : die "Not 10 digits.\n"; } sub uniq { return $_[0] !~ /(.).*\1/ }
|
|---|