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
Remember: Ne dederis in spiritu molere illegitimi!

In reply to Re: Question about returning array from sub by 1nickt
in thread Question about returning array from sub by ojagan

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.