in reply to Challenge - Creative Way To Detect Alpha Characters
while ($_ = substr($foo,$i++,1)){ if (++$_**2 == 0) { print "$foo Contains Alpha Characters\n"; last; } }
my $i = 0; while (local $_ = substr($foo,$i++,1)){ if (++$_ == 0) { print "$foo Contains Alpha Characters\n"; last; } }
This breaks at an alpha char, and significantly increases the speed, but it is still ~3 times slower that initial solution.while (++substr($foo,$i++,1) != 0){}
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Challenge - Creative Way To Detect Alpha Characters
by ambrus (Abbot) on Sep 14, 2004 at 15:47 UTC |