use strict; use File::Spec::Functions; use Data::Dumper; # for debugging purpose only my $path = canonpath("../somedir/path/"); print "$path\n"; my @dirs = qw( ../dir/path1 ../dir/path2 ); my @canon_dirs = map { canonpath($_) } @dirs; print Dumper(\@canon_dirs);