for (1..1000) { print "Next number : ", xCount::next_num(), "\n"; } package xCount; sub next_num { if (open(ON, "+; $ordernum += 1; seek ON, 0, 0; print ON $ordernum; flock ON, 8; close(ON); } return $ordernum; } 1;