
how to substitute letters within a string
(snipped)
Quote:
> > I wish to substitute any occurrences of an uppercase I in a variable
> > with the lower case i. I am familiar with using:
> > s/I/i/g;
> $fred =~ tr/I/i/;
Godzilla!
--
GODZILLA DOS BENCHMARK:
_______________________
test1.pl
________
#!perl
$godzilla = "GodzIlla Is an Igenious InventIve InnovatIve Perl Programmer";
$godzilla =~ tr/I/i/;
exit;
test2.pl
________
#!perl
$godzilla = "GodzIlla Is an Igenious InventIve InnovatIve Perl Programmer";
$godzilla =~ s/I/i/g;
exit;
PRINTED RESULTS:
________________
C:\APACHE\USERS\TEST>godzilla -N10 perl test1.pl
Average Time: 50 ms
C:\APACHE\USERS\TEST>godzilla -N10 perl test2.pl
Average Time: 77 ms
BENCHMARK TESTING:
__________________
#!perl
print "Content-type: text/plain\n\n";
use Benchmark;
print "Run One:\n\n";
&Time;
print "\n\nRun Two:\n\n";
&Time;
print "\n\nRun Three:\n\n";
&Time;
sub Time
{
timethese (1000000,
{
'name1' =>
'$godzilla = "GodzIlla Is an IgenIous InventIve InnovatIve Perl Programmer";
$godzilla =~ tr/I/i/;',
'name2' =>
'$godzilla = "GodzIlla Is an IgenIous InventIve InnovatIve Perl Programmer";
$godzilla =~ s/I/i/g;',
} );
}
PRINTED RESULTS:
________________
Run One:
Benchmark: timing 1000000 iterations of name1, name2...
Run Two:
Benchmark: timing 1000000 iterations of name1, name2...
Run Three:
Benchmark: timing 1000000 iterations of name1, name2...