Write a one liner to dump out a module’s runtime dependencies… †
What would this return? †
$str = "This is a test";
$str2 = substr($str, -2);
How would you interchange the keys and values to a hash like this: †
%hash = ( foo => 1, bar => 2, baz => 3); # before
%hash2 = ( 1 => foo, 2 => bar, 3 => baz); # after
Which would you use and why? †
if (index($foo, "text to find") > -1) { # Option 1
if ($foo =~ /text to find/) { # Option 1
Please explain the following and how you would re-write it: †
my @sorted_list = sort{str2time($b->{$sort_by}) <=> str2time($a->{$sort_by})} @payload;
How would you re-write this? Can you spot the typo? †
if (($aggregate->{m}->{rev}+$aggregate->{c}->{rec}) > 0 && ($aggregate->{m}->{imp}+$aggregate->{c}->{imp}) > 0) {
$aggregate->{ecpm} = (($aggregate->{m}->{rev}+$aggregate->{c}->{rev}) / (($aggregate->{m}->{imp}+$aggregate->{c}->{imp}) / 1000));
}
What does this do and how would you do it differently? †
my %boost_factors = (
map {
my $l = $_ < 0
? (($_ + 10) * 10)
: (($_ + 1) * 100);
($_, $_ && "$l%")
} -9 .. 9
);
Explain and show how you would re-write (if needed) the following: †