/usr/share/doc/libstring-formatter-perl/examples/bench.pl is in libstring-formatter-perl 0.102084-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | #!/usr/bin/perl -l
use strict;
use lib 'lib';
use String::Formatter;
# Ha ha ha. I am avoiding AutoPrereq from the following.
eval "
use Benchmark;
use Template;
use String::Format;
";
my $hash = {
a => 'apples',
b => 'bananas',
};
my $fmt = String::Formatter->new({
codes => $hash,
});
my $index_format = String::Format->stringfactory($hash);
my $tt2 = Template->new;
print $index_format->("I like to eat %a and %b.");
print $fmt->format("I like to eat %a and %b.");
$tt2->process(\'I like to eat [%a%] and [%b%].', $hash, \my $str);
print $str;
timethese(100_000, {
dlc => sub { $index_format->("I like to eat %a and %b.") },
rjbs => sub { $fmt->format("I like to eat %a and %b.") },
# tt2 => sub {
# $tt2->process(\'I like to eat [%a%] and [%b%].', $hash, \my $str);
# },
perl => sub { sprintf("I like to eat %s and %s.", qw(apples bananas)) },
});
|