Reputation:
I 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';
It should output a path to my directory (Pages/TheFileName.aspx
) where I store the converted pages.
However I get this when I print $newFileName
:
.aspx/TheFileName
.aspx
overwrites Pages instead of being concatenated at the end.
I've tried hundreds of other combinations but the second concatenation just overwrites my text. It's the exact same line, which is working in my other script.
Upvotes: 0
Views: 212
Reputation: 2947
Exact content of $newFileName seems to be
"Pages/TheFileName\r.aspx"
which, when printed out looks like
.aspx/TheFileName
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.
Upvotes: 1