Move some shared functions out of lang/perl.c

With any luck these will be useful for other programs...  The idea is
that I've moved all the yucky, non type-safe stuff into its own file.
This lets me somewhat approximate the niceness of GCC in standard C.
Remove lambda.h from lang/bash.c

This essentially just ports over the changes from "lang/perl.c",
taking advantage of the new shared functions to be a bit smaller than
before.