Perl strange compilation messages on win32

I am using SciTE to edit a package and running with Perl 5.10.1 on win32 and suddenly I got compilation message that I couldn’t understand.

So I reduce my package to the smallest code that reproduces it in a Bar package.

Here is my Bar.pm package :

package Bar;
sub test{
  #doc
}
1;

Here is how it failed to compile:

>perl -c -e "use Bar;"
Missing right curly or square bracket at Bar.pm line 1, at end of line
syntax error at Bar.pm line 1, at EOF
Compilation failed in require at -e line 1.
BEGIN failed--compilation aborted at -e line 1.

If I remove the line 3 #doc it says “syntax ok” !

So what was wrong? Look at what Perl really read (by looking at binary content):

perl -Mv5.10.1 -MData::HexDump -MFile::Slurp=read_file -e"say HexDump read_file('Bar.pm', binmode=>':raw')"
          00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F  0123456789ABCDEF

00000000  70 61 63 6B 61 67 65 20 - 42 61 72 3B 0D 73 75 62  package Bar;.sub
00000010  20 74 65 73 74 7B 0D 09 - 23 64 6F 63 0D 7D 0D 31   test{..#doc.}.1
00000020  3B                                                 ;

Humm, looks like my line ending is 0x0D ( \r old Mac <OS X standard) rather than 0x0A ( \n *nix standard) or \x0D\x0A (\r\n windows standard).

So I go into SciTE menu “Options>Line End Characters” and oh I saw that CR was selected rather than CR+LF; may I changed this by error…

So I fix this option, click on SciTE menu “Options>Convert Line End Characters”, save and check the file content again:

>perl -Mv5.10.1 -MData::HexDump -MFile::Slurp=read_file -e"say HexDump read_file('Bar.pm', binmode=>':raw')"
          00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F  0123456789ABCDEF

00000000  70 61 63 6B 61 67 65 20 - 42 61 72 3B 0A 73 75 62  package Bar;.sub
00000010  20 74 65 73 74 7B 0A 09 - 23 64 6F 63 0A 7D 0A 31   test{..#doc.}.1
00000020  3B                                                 ;

And now, it should compile successfully:

>perl -c -e "use Bar;"
-e syntax OK