use Cwd qw( realpath ); sub choose_a_directory { my ( $dir ) = @_; $dir = realpath $dir; # .... # .... }