#!/usr/bin/perl # COBOL Killer # Create PIC Clauses Fast! $input = <STDIN>; $input =~ tr/\+/ /; @attr_strings = split (/\&/, $input); foreach $out_str (@attr_strings) { @pair = split (/\=/, $out_str); $attr_value{$pair[0]} = $pair[1]; } foreach $key (keys %attr_value) { $key =~ s/%(..)/pack("c",hex($1))/ge; $attr_value{$key} =~ s/%(..)/pack("c",hex($1))/ge; } print "Content-type: text/html\n\n"; @file = split(/\n/,$attr_value{'cobolcode'}); chomp @file; $linelength = (length $file[0]) - 1; print <<"DONE"; <PRE> * * Code created with COBOL KILLER * http://johnbintz.dragonfire.net/cobolkiller/ * WORKING-STORAGE SECTION. 01 DATA-DEFINITIONS. DONE $time = 0; for ($i = 1; $i < @file; $i++) { $file[$i] =~ s/\n//g; $file[$i] =~ s/\r//g; $file[$i] = substr($file[$i],0,80); for ($j = length $file[$i]; $j < $linelength; $j++) { $file[$i] .= ' '; } @words = split(/\b/,$file[$i]); chomp @words; print " 05 LINE-$i.\n"; $time -= 60; foreach $word (@words) { $time += 20; if ($word =~ /XX/) { print " 10 ALPHA-FIELD PIC X("; print length $word; print ").\n"; } elsif ($word =~ /99/) { print " 10 NUMBER-FIELD PIC 9("; print length $word; print ").\n"; } else { print " 10 FILLER PIC X("; print length $word; print ")\n"; print " VALUE \"$word\".\n"; } } } $min = int($time / 60); $sec = $time % 60; print <<"DONE"; * * Time saved: $min Min $sec Sec * </PRE> DONE
In reply to COBOL Killer by johncoswell
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |