use strict; use warnings; use POE; my $in = 0; my $count = shift || 1000; POE::Session->create( inline_states => { _start => sub { rand () ** 2 + rand () ** 2 < 1 && $in ++ }, }, ) for 1 .. $count; POE::Kernel->run(); printf "Pi equals %f\n", 4 * $in / $count;