CodeSOD: Reloaded Commands |
William Heimbinger joins the ranks of developers who come to us to confess their sins. This particular sin was committed when he was but a young child of fifteen years old, which raises more questions than it answers.
Young William was writing Perl and building an anti-spam bot for IRC channels. As he wrote code, he wanted to quickly reload the module to test it, but actually learning how to reload modules looked like too much work. William decided to reinvent that wheel, using a hammer he already knew.
With a trivial block of Perl code:
foreach my $command ( @{$::commands->{command}} ) {
if ($cmd=~/$command->{cmd}/) {
eval $command->{content}; warn $@ if $@;
}
}
William could reload all of the commands his bot needed to handle. And what, exactly, was he loading them from? Why, an XML file, of course.
This combination of XML and Perl may have had some serious side effects on Williams mental health, or perhaps theyre just a sign of a disturbed mind. Either way, this design has been removed from the current version of his bot.
[Advertisement] Use NuGet or npm? Check out ProGet, the easy-to-use package repository that lets you host and manage your own personal or enterprise-wide NuGet feeds and npm repositories. It's got an
impressively-featured free edition, too!
| Комментировать | « Пред. запись — К дневнику — След. запись » | Страницы: [1] [Новые] |