I started programming with perl last week and perl is my first language so I'm a bit of a newbie. Basically I need help with a multidimensional array.
I have a 100k by 3 multidimensional array, contained in a CSV file. Each constituent array is a point in a 2D space with an intensity value taking up the third entry. But I need perl to calculate the norms of each constituent array and add those as a fourth column to this multidimensional array. So I would have a 100k by 4 multidimensional array.
Here's my code: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); #calculate +s the norm push(@data[i],$norm); #pushes the norm into the correct row of + @data, yet I get an error. } }
Specifically my syntax checker tells me that the "Type of arg 1 to push must be array (not array slice) near "$norm)"
Aid me wise monks!
In reply to pushing multidimensional arrays by afalsename
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |