Perl solution to first exercise