but I imagine it'd be hard to make it wget-able and build it into a single file.
While I think solving this in pure-perl is probably do-able, if you do want to drop to C, you could checkout Inline::C.
This allows you do to exactly what you want, embed C in your perl file and have it All Just Work.
(It does require a working C build environment where you run the script, and it will also write the .o/.so files generated by the compiler to a cache so that it only compiles as needed. This might create deployment issues.)