$|=1; # So that the output isn't buffered

# Here we are assigning some numbers to variables
$a=5;
$b=6;
$c=7;

# We are copying these variables into an array
@nums = $a,$b,$c;

# We create a new array with the doubles of the old array
@newnums = &double(@nums);

# We are looping over each element of the array and summing them
foreach $n (@newnumbs){
  $sum = $sum + $n;
}

# To get the mean we devide the sum by the number of elements
$elements = $#newnums + 1;
$mean = $sum / $elements;

# And finally we return the result
print "The mean of doubled values is $mean";

# This doubles all the values of an array
sub double {
  my @n = @_;
  my $number;
  foreach $number (@n){
    $number = $number x 2;
  }
  return @n
}
