my @data = ( [1 .. 3], [4 .. 6], [7 .. 9] );
norm();
print join(", ", @{$_}), "\n" for @data;
sub norm{
$p=$#data; #I call the 100k x 3 array @data
for($i=0;$i<=$p; $i++){ # iterates down @data
$norm=(($data[$i][0])**2+($data[$i][1])**2)**(1/2); #calculates the norm
$data[$i][3] = $norm;
}
}
####
#!/usr/bin/perl
use warnings;
use strict;
my @data = ( [1 .. 3], [4 .. 6], [7 .. 9] );
norm();
print join(", ", @{$_}), "\n" for @data;
sub norm{
my $p=$#data; #I call the 100k x 3 array @data
for(my $i=0;$i<=$p; $i++){ # iterates down @data
my $norm=(($data[$i][0])**2+($data[$i][1])**2)**(1/2); #calculates the norm
$data[$i][3] = $norm;
}
}
####
sub norm{
for(@data){ # iterates down @data
my $norm=(($$_[0])**2+($$_[1])**2)**(1/2); #calculates the norm
$$_[3] = $norm;
}
}
####
#!/usr/bin/perl
use warnings;
use strict;
my @data = ( [1 .. 3], [4 .. 6], [7 .. 9] );
norm(\@data);
print join(", ", @{$_}), "\n" for @data;
sub norm{
my $ar = shift;
for(@$ar){ # iterates down @data
my $norm=(($$_[0])**2+($$_[1])**2)**(1/2); #calculates the norm
$$_[3] = $norm;
}
}
####
sub norm{
my $ar = shift;
for(@$ar){ # iterates down @data
$$_[3]=(($$_[0])**2+($$_[1])**2)**(1/2); #calculates the norm
}
}