It's kind of cheating to use perl for some of it, don't you think? I know this was just an experiment, and the actual networking part is pure bash, but the title is still misleading.
Still, this is certainly interesting and not something I'd considered.