While working for one of the top-5 pharmaceutical companies, Daniel Drucker was handed some legacy Perl 4 stuff and told to "patch it up". Surprise, surprise, the code had some rather ... unique ... ways of doing things. Not to be out done by the guy who invented functions, the coder came up with his own way to create indexed groups of strings.

$roles = "usersuper useradministratordenied";
$roles_offsets = "000004014027";

Get it? The offset of "user" is 000, "super user" 004, and so on. The code would then extract each by iterating through the offsets with substring functions and finding the proper offsets, then using the offset to extract the right substring. There were also some useful methods like push and pop on top of this.

Daniel found some other neat things as well:

Along the way he "invented" file locking (using a master file which contained a list of files to be locked -- he apparently never thought of what might happen if the master file itself was open by two processes...), persistent storage, and a host of other trivial things. If you look at it from his perspective, he must think he's a genius -- I mean, sheesh: he single handedly invented the concept, or at least the implementation of, arrays!

Oh, and it gets better -- in one place he opens a file, reads a filename in from the file, assigns the filename to a variable, passes the variable in a web page in javascript, then gets the variable value back under a different name via CGI, assigns it to another variable, and finally actually opens the named file.

I ended up replacing TWELVE THOUSAND lines of his code with just two hundred.

Feel free to Rate the thread; it's a heck of a lot easier than commenting. There's a button on there somewhere. Also, let me know if you have any complaints/issues with the new RSS feed(s) -- I can tweak them as necessary.

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!