use Path::Class; my $file = file($filepath,"test.txt"); #### $filepath =~ s{/}{\}g; $file = $filepath . "\test.txt";