I have a very simple perl script that moves files (don't ask why i cant use cp, its long, sad, and will make you cry). I take 2 inputs from command line, dir1 and dir2. Then i have an internal file list i pull and concatenate the two together.
my $file = dir1 . filename
That works great as long as the user puts a traling / on their directory. But obviously if they don't it still concatenates it as /my/awesome/folderFILE and the scripts fails.
What is the best practice for sanitizing user supplied directories?