in reply to Finding sum of all digits from 1 to 1 million.

..FROM ONE TO ONE MILLION INCLUSIVE

Your program has:

for ($i=0; $i<1e6; $i++) { ...
You're missing 1,000,000 and so are off by one.
Here's another way (which is still the long way, BTW):
my $total; for (1..1_000_000) { $total += $_ for split ""; } print "$total\n";