#!/usr/bin/perl # Matrix math for the 3000 DSM graphs. use Math::Matrix; # candidatesXYZ.dsm for XYZ = 000 to 999. for ($i = 0; $i <= 999; $i++) { if ($i < 10) { $var_name = "candidates00$i"; } elsif ($i < 100) { $var_name = "candidates0$i"; } else { $var_name = "candidates$i"; } #$$var_name = new Math::Matrix ([line], [line], [line] open(FH, "<../spices-output/$var_name.dsm"); @lines = ; close(FH); foreach my $line (@lines) { @numbers = split(/\,/, $line); $line2 = ""; foreach my $num (@numbers) { if ($num == "") { $line2 .= "0,"; } else { $line2 .= "$num,"; } } $line2 = substr($line2,0,-3); $innerguts .= "[$line2],\n"; } chomp($innerguts); # Get rid of the last new line. print "\$$var_name = new Math::Matrix ($innerguts);\n"; $innerguts = ""; # The absence of this line leads to a very nasty 18 GB file. Yay perl! }