# My memory of the gist of what's in the book, a few hours after having looked it up:
my $thing = do {
if ($cond1) { "Foo" }
elsif ($cond2) { "Bar" }
else { "Baz" }
};
####
my $thing = do {
($cond1) ? "Foo" :
($cond2) ? "Bar" :
"Baz";
};
##
##
my $thing = ($cond1) ? "Foo" :
($cond2) ? "Bar" :
"Baz";
##
##
my $thing = do {
my $rn = int(rand(6))+1;
($rn == 6) ? "Excellent roll" :
($rn > 3) ? "Pretty good roll." :
($rn == 1) ? "Lousy Roll" :
"Meh.";
};
##
##
sub agent {
my $self = shift;
return $self->{_agent} //= do {
require config;
my $agent_args = $config::config{'agent_args'};
require Agent;
return Agent->new($agent_args);
};
}