I am trying to append a path to the end of my PERL5LIB
environment variable, but I am not sure that this variable will always exist. If it doesn't exist I would like to simply initialize it to the value that I am trying to append.
Here is an example that works:
if ( $?PERL5LIB ) then
setenv PERL5LIB ${PERL5LIB}:/some/other/path
else
setenv PERL5LIB /some/other/path
endif
While this works, it still seems pretty clunky since I have to basically write the same line twice. What I would like to do is come up with a more efficient one line solution (possibly using parameter expansion).
Is there a way to consolidate this to one line? (Or a couple lines that don't involve writing out "/some/other/path" multiple times)
For example this could be done in bash:
export PERL5LIB=${PERL5LIB:+${PERL5LIB}:}/some/other/path