- or download this
#!/usr/bin/perl -w
use strict;
...
'Using Unpack' => \&using_unpack,
'Using Reverse & Chop' => \&using_reverse_chop,
});
- or download this
[earino@localhost earino]$ ./first_char.pl
Can't modify reverse in chop at ./first_char.pl line 27, near "$string
+;"
Execution of ./first_char.pl aborted due to compilation errors.
[earino@localhost earino]$
- or download this
return chop reverse scalar $str;
- or download this
#!/usr/bin/perl -w
use strict;
...
'Using Unpack' => \&using_unpack,
'Using Reverse & Chop' => \&using_reverse_chop,
});
- or download this
Benchmark: running Using Regexp, Using Reverse & Chop, Using Split, Us
+ing Substring, Using Unpack, each for at least 5 CPU seconds...
Using Regexp: 5 wallclock secs ( 5.39 usr + -0.01 sys = 5.38 CPU) @
+207251.30/s (n=1115012)
Using Reverse & Chop: 4 wallclock secs ( 5.23 usr + 0.00 sys = 5.23
+ CPU) @ 255457.74/s (n=1336044)
Using Split: 5 wallclock secs ( 5.25 usr + 0.01 sys = 5.26 CPU) @ 9
+7116.92/s (n=510835)
Using Substring: 5 wallclock secs ( 5.25 usr + -0.02 sys = 5.23 CPU)
+ @ 1009882.22/s (n=5281684)
Using Unpack: 5 wallclock secs ( 5.27 usr + 0.01 sys = 5.28 CPU) @
+260676.33/s (n=1376371)