Pi in Perl

$end=1000000;
for($i=1;$i<=$end;$i++) {
$x=rand();$y=rand();
if ($x*$x+$y*$y < 1) {$c++;}
}
print "pi= ",4*$c/$end;

Suppose we have a floor made of parallel strips of wood, each the same width, and we drop a needle onto the floor. What is the probability that the needle will lie across a line between two strips? How does this relate to the above code of “calculating” Pi in Perl? Check out this video: Buffon’s Needle and this Chocolate Pi Calculator