use strict; use warnings; use File::Spec qw(canonpath); my $dir_str = "test/home/players/demo//thumbs/super.jpg"; print File::Spec->canonpath($dir_str);