Eeeek. That code would've been terrible practice in 2000 when I first started writing Perl :(<p>The Mysql module was deprecated in favour of the unified DBI interface, cgi-lib.pl was a <i>perl4</i> library that was replaced by a module called CGI (shipped with perl5 itself from 5.4+).<p>Calling functions with & is a perl4-ism and almost always the wrong thing to do in perl5, and C-style for is silly in most cases in Perl - for example; the loops in there would likely be better redone as foreach loops, or possibly just a grep.<p>And, of course, YAY not using placeholders in the SQL.<p><i>sigh</i>
This is different code than the 2007 PHP code here: <a href="https://gist.github.com/nikcub/3833406" rel="nofollow">https://gist.github.com/nikcub/3833406</a>
What's funny is the kind of interview questions they ask at Facebook. They act is if they are rocket scientists creating major breakthrough algorithms.
At least they had "use strict" turned on. Not sure why they weren't using DBI and placeholders to prevent SQL injection attacks in 2005.
It's surprising to me how "old school" this code is for 2005. It looks similar to Perl code from the late 90's when CGI scripts and form mailers were all the rage.
Would someone be so kind as to explain the following:<p><pre><code> sub morph {
my ($number) = @_;
return ((((($number % 7) * 13) % 17) * 19) % 23);
}
</code></pre>
It appears to be some sort of quick authorization check (there is a later `$code == &morph($user)` comparison).