Data::Dumper will help you immeasurably when working with complex data structures.
use Data::Dumper; say Dumper \@rot_mat;
When you did
$rot_mat[0][0]=cos($phi_rad)*cos($theta_rad)*cos($psi_rad)-sin($phi_ra +d)*sin($psi_ +rad);
Perl automagically created an anonymous array as the value of the first element in the array, and assigned your data to the first element of the anonymous array.
You just need to dereference it.
#!/usr/bin/env perl use strict; use warnings; use Data::Dumper; use feature qw/ say /; my @a; $a[0][0] = 'foo'; $a[0][1] = 'bar'; $a[1][0] = 'baz'; $a[1][1] = 'quux'; say Dumper @a; say $a[0]; for ( @a ) { say (join ' ', @{ $_ }); }
[05:58][nick:~/monks]$ perl 1134141.pl $VAR1 = [ 'foo', 'bar' ]; $VAR2 = [ 'baz', 'quux' ]; ARRAY(0x7feb6b006280) foo bar baz quux
In reply to Re: Question about returning array from sub
by 1nickt
in thread Question about returning array from sub
by ojagan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |