Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
#!/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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-03-29 14:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found