Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

comment on

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

Recently I wanted to use some code in a script I wrote so I thought of getting it from CPAN.
I wanted to use something to get cmd arguments and their values and this seemed nice(it was nice before looking at the source code).
After some time I looked at the module and wondered what could be in.
Covered with curiosity I couldn't resist not pressing the SOURCE CODE link to
see what could lie behind it.
What I found took was a BIG surprise,IT WAS A COMPLETE AND UTTER PILE OF OVERBLOATED CRAP!
I mean,without any disrespect for the author(which I don't know and hope will not need to anytime soon).
Arguments summary:
  • totally unreadable
  • too big compared to what it does
  • contains hidden "logic" that is NOT documented

I propose the following code which is cleaner and more readable:
11 my $params; 12 while(@ARGV){ 13 my $a=shift @ARGV; 14 unless(@ARGV) { 15 $params->{$a}=""; 16 last; 17 }; 18 if($a =~ /^-/) { 19 my $b=shift @ARGV; 20 unless($b){ 21 $params->{$b}=""; 22 last; 23 }; 24 if($b !~ /^-/){ 25 $params->{$a}=$b; 26 } else { 27 $params->{$a}=""; 28 unshift @ARGV,$b; 29 }; 30 }; 31 }
And all these for a simple module !

Update: 20101029 Content restored by Corion


In reply to how did this module get into CPAN ?! by spx2

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 browsing the Monastery: (7)
As of 2024-04-19 10:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found