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

Pages: 1-

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-20 19:54

wow... almost IHBT

Name: Anonymous 2010-09-20 20:24

That's perfectly legible. It's also fucking stupid, but that's a given, with Perl programmers.

Name: Anonymous 2010-09-20 22:12

It's fine. It works for me.

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.

Name: Anonymous 2010-09-21 4:53

>>5 But it doesn't mean that you can't

Name: Anonymous 2010-09-21 5:07

I see your problem ; you are converting from metric to dinosaur .  It is crealry only meaningful to convert the other way , for reasons like e.g. helping archæologists decipher the arcane measurement systems used by certian primitive cultures .

Name: Anonymous 2010-09-21 5:49

YHABT

Name: Anonymous 2011-02-03 3:56

Name: Anonymous 2011-02-18 13:59

<-- that's cool and all, but check 'em

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