#!/usr/bin/perl -w use strict; # 1188105 my @data = qw(1 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 2 1 1 0 0 0 0 0 1 1 0 0 0 1 0 0 0 1 3 1 1 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 4 1 1 1 0 0 0 0 0 0 1 0 0 0 0 0 1 0 5 1 1 0 0 0 0 0 1 1 0 0 0 1 0 0 0 1 6 1 1 0 0 0 0 0 1 1 0 0 0 1 0 0 0 1 7 1 1 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 8 1 1 0 0 0 0 0 1 1 0 0 0 1 0 0 0 1 9 1 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 10 1 1 0 0 0 0 0 1 1 0 0 0 1 0 0 0 1 11 1 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 12 1 1 0 0 0 0 0 1 1 0 0 0 1 0 0 0 1 13 1 1 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0); my $linemarker = " xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; my $item; my $seen = '0'; print "\n(\n"; # op wants to start (& end) the printout with a paren, # but -- in practice -- if the array is read from # a "binary file," AS STATED, there won't be any parens # in the array for $item(@data) { if ( $item !~ /\d+/ ) { $item = ord($item); # xlate char to num } elsif ( ($item == 1) && ($seen =~ /0/) ) { # first array element? # Then it's a linenumber (LN) print "$item "; # so print LN with spacing $seen = "seen"; # set flag so future number 1s won't be taken for LNs next; # and move on to next array element } elsif ( (10 > $item) && ($item > 1) && ($seen =~ /seen/) ) { # HACK to line up the elements print "\n$linemarker\n$item "; next; } elsif ( (100 > $item) && ($item > 9) && ($seen =~ /seen/) ) { print "\n$linemarker\n$item "; # if LN > 9 and < 99, # print fewer spaces -- end HACK } else { print "$item "; } } print "\n)\n";