Or what I've found but never used myself is setting the filemode to binary with binmode()
This lines should be added at the beginning of your Perl script:
binmode(STDIN, ':crlf');
binmode(STDOUT, ':crlf');
binmode(STDERR, ':crlf');
Thanks nostr:npub175nul9cvufswwsnpy99lvyhg7ad9nkccxhkhusznxfkr7e0zxthql9g6w0
I am struggling with converting a perfectly working program on Linux into a Windows version
Can't believe a simple text file is handling differently in Windows (because at the beginning a character is detected in Perl)
The program I posted in the Article, is actually not working because of that ...
Or what I've found but never used myself is setting the filemode to binary with binmode()
This lines should be added at the beginning of your Perl script:
binmode(STDIN, ':crlf');
binmode(STDOUT, ':crlf');
binmode(STDERR, ':crlf');
after a long troubleshooting, I finally understands what went wrong
This is how I created the pwd.txt file
echo "abcde" > pwd.txt
and by doing so, it generated a UTF-16 encoded file, which has the annoying habit of having invisible characters added to it at the beginning and in between the characters as well ...
Windows stuffs
I realized all this because of the use of 'echo' in the Windows terminal
once I used Perl to write the pwd.txt file, everything went fine ... no surprise, no added extra characters
the file generated by the echo command had a BOM invisible character at the start, FF FE and 00 every second character because UTF-16 requires two code units to represent a single character.
surprise, surprise
I see, encoding issues.