PATH=$(perl -e 'print join ":", grep -d, split ":", $ENV{PATH}')
(this doesn't mean the shell clever is bad, it just means I don't find -that- dialect of line noise as skimmable)
$^path(N) is an equivalent to your perl expression. The snippet throwaway84846 posted also removes duplicates and collapses symlinks from /usr-merge for example.