Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

How readable is my code?

Name: Anonymous 2010-09-20 19:43

I mean, code's gotta be easy for other people to understand, right?

$answer = $original_measure * 0.3937008;
            # but because that inevitably results in 1583 decimal places
            $answer = sprintf "%.2f", $answer; # weird, but at least it works
            $sign = $answer < 0; #catch the sign; keep it here for later
            $answer = abs $answer; # throw the sign away
            $answer_feet = int($answer/12);
            $answer_inches = $answer - ($answer_feet * 12);
           
           
            $answer_string = "$original_measure centimetres equals "
                            . (($sign) ? "-" : "")
                            . (($answer_feet) ?
                               ($answer_feet == 1) ? "1 foot" :
                                          "$answer_feet feet" : "")
                            . (($answer_inches) ?
                               (($answer_feet) ? " " : "") .
                               (($answer_inches == 1) ? "1 inch" :
                                        "$answer_inches inches") : "")
                            . ((!$answer) ? "0 inches" : "");

Name: Anonymous 2010-09-21 4:42

Please use PERL CRITIC and also stop using retarded variable names.  IHBFT
Perl forces you to mutate a lot, but it doesn't mean that you have to mutate absolutely fucking everything.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List