I've recently wrote a converter, which takes our old wiki pages and converts them into SharePoint Pages.
All this was done via command line, but now I switched to GUI with Win32.
I'm still new to perl and just copied my working code to my new.pl with fancy GUI things.
Everything works expect this line:
$newFileName = 'Pages/'.$file.'.aspx';
Exact content of $newFileName seems to be
which, when printed out looks like
because included "\r" (carriage return) causes cursor to go to start of the line so that ".aspx" overwrites "Pages" on screen.
So simple fix (as already mentioned in comments) is to remove "\r" from $file, e.g. with
$file =~ s/\r//g;
Problems like this can be quite common in Windows because in Windows newline is "\r\n" while many unix-like programs except "\n", so it's easy to have that extra "\r" left in strings.