LD_LIBRARY_PATH is set for the perl executable when the perl executable is started. You can set in in the perl script, but it is not going to impact the running program (e.g. perl itself). If the loader (ld.so in linux) does not know about a library when perl starts, changing the environment variable at runtime won't tell it). In other words, it's "too late". ld.so has already copied the LD_LIBRARY_PATH environment variable into is memory, started the program and left.