OSDN Git Service

This are the offline edits.
[fig-forth-6809/fig-forth-6809.git] / socialize6809.pl
1 #!/usr/bin/env perl
2
3   use v5.010.000;
4   use warnings;
5   use strict;
6
7 #  say "Hello World!";
8
9 #  print $ARGV[ 1 ];
10
11
12 while ( my $line = <> )
13 {
14   if ( $line =~ m/^(\w*)\s+FCC\s+(\d+),(.*)$/ )
15   {
16     my $label = $1;
17     my $symlength = $2;
18     my $strfield = $3;
19     my $symbol = substr( $strfield, 0, $symlength );
20     my $leftovers = substr( $strfield, $symlength );
21     my $strlength = length( $symbol );
22     if ( $strlength < $symlength )
23     {
24       print "$label\tFCC error\t'$symbol' not complete to "
25             . "$symlength characters (only $strlength). ****error***";
26     }
27     else
28     {
29       my $fullsymbol = $symbol;
30       if ( $leftovers =~ m/^(\S+)(.*)$/ )
31       {
32         $fullsymbol .= $1;
33         $leftovers = $2;
34       }
35       print "$label\tFCC\t'$symbol'\t; '$fullsymbol'";
36     }
37     
38     if ( length( $leftovers ) > 0 )
39     {
40       print " : $leftovers";
41     }
42     print "\n";
43   }
44   else
45   {
46     print $line;
47   }
48 }
49