in reply to add a character at the end of a string

The portable way would be to use core module File::Spec's catpath to join the dir to the filename instead of playing with slashes.