in reply to Create matrix and save to a file

A convenient method I use to save an arbitrary structure of data to a textfile is to use our famous Data::Dumper core module to capture the variable's content in a string.
When I need it again I just use an eval to convert the string back into my matrix or other datastructure.
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my @data = (0,1,2,3 ); print "BEFORE: ",join(',',@data),"\n"; my $saved_data = Dumper(\@data); # ...here you would write saved data to textfile my $VAR1; eval $saved_data; my @data2 = @{$VAR1}; print "AFTER: ",join(',',@data2),"\n";
Output would be:
BEFORE: 0,1,2,3 AFTER: 0,1,2,3