in reply to Adding directories to the end of @INC isn't very large or complicated - how about making a copy with a new name (lib::append, maybe?) and replacing the unshift(@INC,...)s with pushes? And perhaps add a couple of reverses if you want duplicate-removal to leave the last instance of a directory instead of the first:

# remove trailing duplicates ## @INC = grep { ++$names{$_} == 1 } @INC; # remove leading duplicates @INC = reverse grep { ++$names{$_} == 1 } reverse @INC;


"Any sufficiently analyzed magic is indistinguishable from science" - Agatha Heterodyne