#!/usr/bin/perl # Monte Carlo approximation of PI. Slow! use strict; use warnings; my $in = 0; my $count = @ARGV ? shift : 1000; rand () ** 2 + rand () ** 2 < 1 && $in ++ for 1 .. $count; printf "Pi equals %f\n", 4 * $in / $count;