#!/bin/bash eval 'LD_LIBRARY_PATH=/my/lib /usr/bin/perl /the/script' if $runningUnderSomeShell; warn "$ENV{LD_LIBRARY_PATH}\n";