http://qs321.pair.com?node_id=118056


in reply to "switch$ia" but don't interpolate trailing "a"

I have to assume someone has done this before, but I didn't see it, so...

Benchmarking interpolated strings vs. appended strings:

use Benchmark; timethese( 1000000, { interp => sub {my $R = 1; my $S = "Test${R}a"}, append => sub {my $R = 1; my $S = 'Test' . $R . 'a'} });
results in:
Benchmark: timing 1000000 iterations of interp, manual... interp: 4 wallclock secs ( 3.68 usr + 0.05 sys = 3.73 CPU) @ 2680 +96.51/s manual: 3 wallclock secs ( 3.79 usr + -0.13 sys = 3.66 CPU) @ 2732 +24.04/s
Slightly faster to append strings together than to interpolate them, but statistically, it's a wash...

Russ
Brainbench 'Most Valuable Professional' for Perl