Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
No such thing as a small change
 
PerlMonks  

Comment on

( #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":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others exploiting the Monastery: (4)
    As of 2014-04-20 21:08 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      April first is:







      Results (487 votes), past polls