sub norm{ for(@data){ # iterates down @data my $norm=(($$_[0])**2+($$_[1])**2)**(1/2); #calculates the norm $$_[3] = $norm; } }