#!/usr/bin/perl my $currstate=-1; my @states; my @final; my $tn=0; while(<>) { if(/^\s*([0-9]+)\s+([0-9]+)\s+(.)(\s*)?$/) { push @{$states[$1]}, ($3, $2); $#states=$2 if $#states<$2; $tn++; } elsif(/^\s*([0-9]+)\s*$/) { $final[$1]=1; $#states=$1 if $#states<$1; } else { die("Input error."); } } print scalar(@states)," ",$tn," char void\n"; my $i=0; my $width=int(log(@states+1)/log(10)); foreach $stateref (@states) { $f = ($final[$i]?"+":"-"); printf "%${width}d %s",$i++,$f; while(@$stateref) { $c=shift @$stateref; $s=shift @$stateref; print " $c $s"; } print "\n"; }