http://www.perlmonks.org?node_id=1002816


in reply to Is it possible to get the inverse of a square matrix to be input as a text file using STDIN?

One of the things to learn about any programming language is that your problem has almost certainly been addressed in some way before, and in this case there are PERL CPAN libraries like Math::Matrix and Math::MatrixReal to avoid having to do any work. Using CPAN libraries also makes your code more maintainable as other people will have more chance of having come across the library concerned on CPAN than of understanding your custom code.

In answer to the input question, (and modifying an earlier answer) why not get your input as

while (<>) do { push @m2, [ split /,/, $_ ]; }
and then your script can get your input from any file or stdin....
e.g.
./myprogram.pl < d1.txt

  • Comment on Re: Is it possible to get the inverse of a square matrix to be input as a text file using STDIN?
  • Select or Download Code

Replies are listed 'Best First'.
Re^2: Is it possible to get the inverse of a square matrix to be input as a text file using STDIN?
by supriyoch_2008 (Monk) on Nov 09, 2012 at 04:36 UTC

    Hi, space_monk

    Thank you very much for providing valuable suggestions, particularly about CPAN. The idea did not come to my mind before posting the question in Seekers of Perl Wisdom. I shall try to use Math::Matrix perl module.

    With regards