in reply to String validation
I did a bit of benchmarking of uc vs. tr, and the results were pretty similar:if ($string =~ m!(^[A-Za-z0-9]{4})$!) { $string =~ tr/[a-z]/[A-Z]/; # or $string = uc $string; # do something } else { # do some error }
So they should be pretty much interchangeable, in terms of performance.Benchmark: timing 1000000 iterations of tr, uc... tr: 10 secs ( 7.49 usr 0.00 sys = 7.49 cpu) uc: 9 secs ( 6.60 usr 0.00 sys = 6.60 cpu)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
You're right...
by chromatic (Archbishop) on Mar 25, 2000 at 02:25 UTC | |
by btrott (Parson) on Mar 25, 2000 at 02:36 UTC |