#!/usr/bin/perl -w $sum=0; $count=0; while ($count <50) { $count++; #this is tricky in the last loop $count is 49 and then increased to 50 and added $sum += $count; }; print "$sum\n"