http://qs321.pair.com?node_id=11121995


in reply to Finding sum of numbers and storing it an Array

With minimal editing...

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11121986 use warnings; my @numbers = ( my $num1 = 5, my $num2 = 10, my $num3 = 15, my $num4 = 20, my $num5 = 25, ); my $totalSum = 0; $totalSum += $_ for @numbers; $_ /= $totalSum for my @array = @numbers; # just to confuse your t +eacher print "The required numbers are: @array\n";

Outputs:

The required numbers are: 0.0666666666666667 0.133333333333333 0.2 0.2 +66666666666667 0.333333333333333