use Loop::Watch;
my $temp = 20; # celsius, that is
# doing { ... } does *not* loop
ensure { $temp >= 0 } watching($temp), doing {
move_to_florida();
wait_until_winter();
move_to_new_jersey();
wait_until_spring();
move_to_montana();
wait_until_fall();
move_to_alaska();
wait_until_winter();
};
####
use Loop::Watch;
my $money = 1_000_000; # in USD
# looping { ... } *does* loop
ensure { $money > 0 } watching($money), looping {
circle_globe();
};
sub circle_globe {
move_to_next_location();
purchase_lodging();
eat();
# ...
}
##
##
use Loop::Watch;
my ($age, @companies);
$age = 20;
ensure { $age < 35 and @companies < 10 }
watching($age, \@companies),
looping {
$age++ if new_year();
if (my $c = acquisition_available()) {
if (try_to_purchase($c)) {
push @companies, $c;
check_related($c);
}
}
};