Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

It's the weekend. Time to get your head out of the production-level code. But not too far - we'd go off-topic. So let's instead think about some of the worst ways to do things.

I don't mean things like `rm $file`;. I'm thinking more along the lines of a daily wtf, but for people who don't automatically think that "perl code" == "line noise". For example:

sub remove_newlines { my $string = shift; my $clean_string = `echo -n $string`; return $clean_string; }
This isn't merely chomp - this is super-chomp. Whether you have one or many new lines at the end of your string, this will clear 'em all out. If you're not shaking your head in disappointment over that code, you're probably not realising that s/\n+$// does the same job - but faster, more reliably (no shell metacharacters to worry about!) and is far more portable.

Sit back, crack open your favourite beverage, share code you'd be embarrassed to check in to source control or upload to CPAN, and enjoy your weekend. :-)


In reply to TIMTOWTDI meets Rube Goldberg by Tanktalus

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 contemplating the Monastery: (7)
As of 2024-04-18 20:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found