OSDN Git Service

Script to convert the character string declarations to the more common form.
[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+),(\S+)(.*)$/ )
15   {
16     my $label = $1;
17     my $symlength = $2;
18     my $strfield = $3;
19     my $leftovers = $4;
20     my $symbol = substr( $strfield, 0, $symlength );
21     my $strlength = length( $symbol );
22     if ( $strlength < $symlength )
23     {
24       my $difference = $symlength - $strlength;
25       $symbol .= substr( $leftovers, 0, $difference );
26       $leftovers = substr( $leftovers, $difference );
27     }
28     print "$label\tFCC\t'$symbol'\t; '$strfield'";
29     if ( $leftovers ne "" )
30     {
31       print " : $leftovers";
32     }
33     print "\n";
34   }
35   else
36   {
37     print $line;
38   }
39 }
40