Fun code problem of the day!

Ovid on 2006-12-05T16:14:40

No one who works here would ever write such a monstrosity and we're not sure exactly where this code originated, but somehow it wound up on a server and a co-worker asked me to take a look and figure out what was up. I knew things were bad when I saw the beginning of it:

die "\nArguments:\n
-a | -p | -x\t\tServers: all / production / eXclude production
\t\t\tDefault: exclude production
-d [-h] | -m \t\tMANDATORY
-n\t\t\t\tMANDATORY
[-i]\t\t\t\t\toptional, specify host
[-s<500|5000>]\t\t\t\t\toptional for HTMLified output.
\t\t\t\t\t\tSize limit in MB.
[-z]\t\t\t\t\t\toptional, HTMLify output
[-t <1-12>]\t\t\t\t\tExclusive option - get totals for month 
\t\t\t\t\tUse in conjunction with either -a, -p, -x
\n\n"
  unless (($opt_a || $opt_p || $opt_x || $opt_i)
    &&
    (((($opt_d || $opt_h) && !$opt_m)
                ||
                (!$opt_d && !$opt_h && $opt_m))
    &&
    (($opt_n && !$opt_i) || $opt_i)) || $opt_t);


Ouch

Matts on 2006-12-05T16:31:28

You owe me new eyes!

Basically...

bart on 2006-12-05T18:57:27

I've not actually run the code, but at first look, it dies with a "usage" message if not an acceptable combination of command line switches, probably originating from Getopt::Std or Getopt::Long, is set.

die $usage unless some_combination_of_opts_set;

Re:Basically...

mitchellfisher on 2006-12-12T05:21:57

found this while googling rentrak... now i'm sick.

Re:Basically...

Ovid on 2006-12-12T07:19:46

Given your response to another journal entry, I expect you might be considering a job with them. I used to work for them and I'm quite happy with them. If they offer you a job, jump at the chance. They have great programmers working for them and you'll learn a ton.