in reply to Question about returning array from sub
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Question about returning array from sub
by QM (Parson) on Jul 10, 2015 at 13:29 UTC | |
by ojagan (Novice) on Jul 10, 2015 at 13:33 UTC | |
by QM (Parson) on Jul 10, 2015 at 13:38 UTC | |
by ojagan (Novice) on Jul 10, 2015 at 14:04 UTC | |
|
Re^2: Question about returning array from sub
by ojagan (Novice) on Jul 10, 2015 at 13:14 UTC | |
by 1nickt (Canon) on Jul 10, 2015 at 14:19 UTC | |
by QM (Parson) on Jul 10, 2015 at 13:36 UTC | |
by ojagan (Novice) on Jul 10, 2015 at 13:45 UTC | |
by 1nickt (Canon) on Jul 10, 2015 at 14:25 UTC |