Math::Matrix returns an object, and you can use arrow syntax to access individual elements:
use strict;
use warnings;
use Data::Dumper;
use Math::Matrix;
srand(time);
my $a = new Math::Matrix ([rand,rand,rand],
[rand,rand,rand],
[rand,rand,rand]);
print Dumper($a);
print $a->[0]->[0]; # get 1 element
__END__
$VAR1 = bless( [
[
'0.83428955078125',
'0.442596435546875',
'0.792205810546875'
],
[
'0.193817138671875',
'0.21514892578125',
'0.23980712890625'
],
[
'0.09869384765625',
'0.627197265625',
'0.514892578125'
]
], 'Math::Matrix' );
0.83428955078125
It is often helpful to look at the tests provided with the CPAN distribution to see example usage code (follow the MANIFEST link to the "t/" links). In this case, the tests do show how to access individual elements.
Super Search is another efficient way of finding answers with code samples:
accessing elements inside Math::Matrix |