IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Re: Bad Perl indeed!
You forgot that sort is by default alphabetical, not numerical.
D'oh!
Useless use of chomp detected.
Old habit.

{snip handy re-write, will test later}
If this was in a larger sample I'd fault the excessive indentation. But in this short of code it isn't worth breaking out functions.
What's wrong with the indentation?
I'm not entirely sure what the messages are either, if full emails then I'd break out early at the end of the header. That would be faster and avoid possible spurious matches.
Yes, they're full emails and this is a damn fine idea.


Moochos grassy arse for your help.


Peter
[link|http://www.ubuntulinux.org|Ubuntu Linux]
[link|http://www.kuro5hin.org|There is no K5 Cabal]
[link|http://guildenstern.dyndns.org|Home]
Use P2P for legitimate purposes!
New The indentation is too deep.
That's a code smell indicating poorly factored complexity.

Cheers,
Ben
I have come to believe that idealism without discipline is a quick road to disaster, while discipline without idealism is pointless. -- Aaron Ward (my brother)
New Okay, now I have to post this
Sorry about the right scroll, but you need it for this one.

\nif (is_array($foonums)) { \n    for($i=0;$i<count($foonums);$i++) { \n        $foonum = $foonums[$i]; \n        if (isByHand($foonum)) { \n            $foos[$foonum] = "hand"; \n        } else { \n            $sql = "SELECT idnum FROM foos_transferred WHERE foonum='".$foonum."'"; \n            if ($db->dbQuery($sql)) { \n                $foos[$foonum] = "transferred"; \n            } else { \n                $sql = "SELECT idnum FROM foos_deleted WHERE foonum='".$foonum."'"; \n                if ($db->dbQuery($sql)) { \n                    $foos[$foonum] = "deleted"; \n                } else { \n                    $sql = "SELECT idnum FROM foos_release WHERE foonum='".$foonum."'"; \n                    if ($db->dbQuery($sql)) { \n                        $foos[$foonum] = "released"; \n                    } else if (substr($foonum,0,1)!='9') { \n                        $foos[$foonum] = "old_system"; \n                    } else { \n                        $foos[$foonum] = "alive"; \n                    } \n                } \n            } \n        } \n    } \n} \n \n... \n \n \nif ($conn->dbQuery($query)) { \n    $success++; \n    logIt('pl_foo/mainlog', $query, $o_User->username); \n#\t\t\techo "<font color='purple' size='2' face='arial'><b>QUERY: ".$query."</b></font><br>"; \n    if ($conn2->dbQuery($query2)) { \n        $success2++; \n        logIt('pl_foo/mainlog', $query2, $o_User->username); \n#\t\t\t\techo "<font color='green' size='2' face='arial'><b>QUERY2: ".$query2."</b></font><br>"; \n        if ($conn3->dbQuery($query3)) { \n            $success3++; \n            logIt('pl_foo/mainlog', $query3, $o_User->username); \n#\t\t\t\t\techo "<font color='magenta' size='2' face='arial'><b>QUERY3: ".$query3."</b></font><br>"; \n        } else { \n            logIt('pl_foo/mainlog', "FAILURE: ".$query3, $o_User->username); \n        } \n    } else { \n        logIt('pl_foo/mainlog', "FAILURE: ".$query2, $o_User->username); \n    } \n    // keep going.  all is well so far.\n} else {\n    logIt('pl_foo/mainlog', "FAILURE: ".$query, $o_User->username);\n    echo "There's an error in the loop";\n    break;\n}\n\n\n...\n\n\n                            } else {\n                                logIt('pl_foo/transferlog', "DID NOT HAPPEN: ".$sql, $o_User->username);\n                                echo "DID NOT HAPPEN: ".$sql."
";\n }\n } else {\n logIt('pl_foo/transferlog', "FAILURE: ".$sql, $o_User->username);\n echo "FAILURE: ".$sql."
";\n }\n } else {\n logIt('pl_foo/transferlog', "FAILURE: ".$sql, $o_User->username);\n echo "FAILURE: ".$sql."
";\n }\n } else {\n logIt('pl_foo/transferlog', "FAILURE: ".$sql, $o_User->username);\n echo "FAILURE: ".$sql."
";\n }\n } else {\n logIt('pl_foo/transferlog', "FAILURE: ".$sql, $o_User->username);\n echo "FAILURE: ".$sql."
";\n }\n } else {\n logIt('pl_foo/transferlog', "FAILURE: ".$sql, $o_User->username);\n echo "FAILURE: ".$sql."
";\n }\n


Things to note:
  • The clsDB->dbQuery method will return -1 on error. PHP interprets 'if( -1 )' as true.
  • The last snippet has 6 different failure modes. Count the number of uniquely identifiable error and/or log messages.
  • Pretty colored debugging messages.
  • Actual linefeeds instead of \\n in strings.
  • Using double quotes instead of single for strings that shouldn't be evaluated, then closing the quotes and concatenating the variables that could be parsed in a double-quoted string.

This isn't even the worst code from this guy.

===

Purveyor of Doc Hope's [link|http://DocHope.com|fresh-baked dog biscuits and pet treats].
[link|http://DocHope.com|http://DocHope.com]
New Ugh
I have come to believe that idealism without discipline is a quick road to disaster, while discipline without idealism is pointless. -- Aaron Ward (my brother)
     It's "Peter Writes Bad Perl" time again! - (pwhysall) - (9)
         Bad Perl indeed! - (ben_tilly) - (4)
             Re: Bad Perl indeed! - (pwhysall) - (3)
                 The indentation is too deep. - (ben_tilly) - (2)
                     Okay, now I have to post this - (drewk) - (1)
                         Ugh -NT - (ben_tilly)
         If you can pipe from STDIN you save a bunch - (broomberg) - (3)
             It's processing a Maildir format directory... - (pwhysall) - (2)
                 OK, you're chuffed - (broomberg) - (1)
                     ICLRPD (new thread) - (drewk)

Sex. Always sex.
118 ms