Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
This probably doesn't belong anywhere, but Meditations is as good a place as any I suppose I was crawling through someone else's code today. I was supposed to go port it to use some new infrastructure of ours, but after I clawed my eyes out, we decided I should rewrite it. The clincher for me was:
for ( @data ) { sysopen ($fh, "$log", O_WRONLY|O_APPEND); $fh->print ("$_"); close $fh; }
This sent me off on a rant. This sent my manager and I off into a tailspin inventing god-awful code. My final contribution is nothing short of contrived ugliness, and I wanted to share it with you, my esteemed fellow monks:
#!/usr/bin/perl my $filename = $ARGV[0]; my @size = grep /./, map { $_ } split //, `wc -l $filename`; my $i = ''; my $loop = 1; while ( $loop ) { my $d = shift @size; if ( $d =~ /\d/ ) { $i .= $d; } else { $loop = 0; } } for ( 1 .. $i ) { my $line = `head -$_ $filename | tail -1`; print $line; }
Since I'm dealing with the ugliness someone else unleashed on the world, somehow I feel better having unleashed that on the world, and it's better to do it here than in real code. This isn't about obfuscation, it's about just plain god awful code that does the job (in this case a version of 'cat'). A reminder of what we strive to not unleash on people. So make me cringe...show me your ugliness.

In reply to Plain old bad code by HuckinFappy

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: (1)
As of 2024-04-25 00:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found