#!/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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.