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