#!/usr/bin/perl -w use strict; # or die :-) my $LIMIT = 1000000; my $s; foreach (1 .. $LIMIT) { foreach (/./g) { $s += $_; } } print "Sum: $s\n";