Please use <code> tags instead of <pre> - pre tags aren't wrapped and break the layout if you have long lines. Code tags also make it easier to download the code. See writeup formatting tips
Anyway, looking at DynaLoader you should be able to add the path to @DynaLoader::dl_library_path, though I'm not sure why setting the environment doesn't work.