#!/usr/bin/perl
#
# Program to convert image text files to GAP matrices. 

$file = '/tmp/im.txt';		# Name the file
open(INFO, $file);		# Open the file
my $line = <INFO>;
@parts = split /(:|,)/, $line;
print("HAPAAA:=List([1..",@parts[2],"],i->[]);\n");
while(<INFO>)		# Read it into an array
{
@parts = split m!(,|:|\(|\))!, $_;
print("HAPAAA[",1+$parts[0],"][",1+$parts[2],"]:=",$parts[6]+$parts[8]+$parts[10],";\n");
};			# Print the array
close(INFO);
