Showing posts with label perl. Show all posts
Showing posts with label perl. Show all posts

Wednesday, August 15, 2007

I really don't think it's fair for me to be just using a simple script as I always do and it to suddenly not be able to call methods it's been using the whole time. I've changed nothing, but suddenly the each method is being called from an undefined iterator in mysqlPP.pm's fetch method.

It's also lame that I can't use CGI in mod_perl. I don't know why, but in CGI, it's fine, but under mod_perl, it isn't, except for when it is, which isn't often. And sometimes it doesn't work in CGI--I thing it was when I also had it trying to work in mod_perl; that is, loading Apache when mod_perl is trying to use CGI means I can't use CGI anywhere at all, and it sucks, because it's pretty darn tricky to handle stuff properly. My Apache::Request wrapper doesn't handle multiple values properly, and I'm too lazy to fix it.

Friday, July 27, 2007

This rule from Perl Best Practices made me laugh and finally realise what twisted, sick-minded individuals Perl programmers really are.

The correct rule is obviously 'Don't cascade ternary operators. Just don't. Use if-else.' But Perl programmers do it our way, and it's as beautiful as it is evil.

Wednesday, July 25, 2007

In the array and hash naming convention guideline in Perl Best Practices, they have this lovely example of when an array name should be singular (answer: when used as a random access table like a hash):

sub factorial {
my ($n) = @_;

croak "Can't compute factorial($n)"
if $n < 0 || $n > $MAX_FACT;

return $factorial[$n];
}
Factorials not pre-calculated for the cache are simply declared incomputable. Talk about lazy programming!

(Code snippet from:
Perl Best Practices, by Damian Conway, Copyright 2005 O'Reilly Media, Inc., ISBN 0-596-00173-8
Good book.)