in reply to Re: Peculiar Error When Loading open Pragma Before Text::CSV_XS Module
in thread Peculiar Error When Loading open Pragma Before Text::CSV_XS Module

Interesting. can you explain why?


Enjoy, Have FUN! H.Merijn
  • Comment on Re^2: Peculiar Error When Loading open Pragma Before Text::CSV_XS Module

Replies are listed 'Best First'.
Re^3: Peculiar Error When Loading open Pragma Before Text::CSV_XS Module
by ikegami (Patriarch) on Dec 24, 2011 at 10:42 UTC

    Nope!

    There was talk on p5p (by Jan Dubois??*) about Perl having to correct the current source file position (when still near the top of the file) to take CRLF endings into account on Windows. Something about reading the source file as a text file, then having to reconstruct the buffer so it would be as if the file had been read as a binary file. Doing so requires assuming the lines end with CRLF. (Well, that's how I vaguely remember it.) I don't remember the context of that talk, but I figured this problem might be related since Perl is apparently treating the middle of a comment as source code.

    * — "Jan Dubois" would be an awesome porn star name. du = from the, of the, some; bois = wood, woods

      If I change the first 4 lines to

      package Text::CSV_XS; # Copyright (c)2007-2011 # H.Merijn Brand. All rights reserved. # Copyright (c)1998-2001 # Jochen Wiedmann. All rights reserved.

      I also pass this command on Windows/Strawberry. I could make that change, but does it help in the end? I mean, the IO bug is still luring in the backyard.


      Enjoy, Have FUN! H.Merijn

        I tried that. It doesn't help. No monkeying with the text on the third line resolves the problem. It only changes the text of the error message.

        Thanks, Tux.

        Jim

      OK, I converted the text file named CSV_XS.pm from Unix format to DOS format (that is, I added CR characters to it).

      C:\>perldoc -l Text::CSV_XS C:\strawberry\perl\site\lib\Text\CSV_XS.pm C:\>chdir C:\strawberry\perl\site\lib\Text\ C:\strawberry\perl\site\lib\Text>bytecnt < CSV_XS.pm | egrep "CR|LF" 10 0A LF 1938 13 0D CR 0 C:\strawberry\perl\site\lib\Text>attrib CSV_XS.pm A R C:\strawberry\perl\site\lib\Text\CSV_XS.pm C:\strawberry\perl\site\lib\Text>attrib -r CSV_XS.pm C:\strawberry\perl\site\lib\Text>rename CSV_XS.pm CSV_XS.pm_LF_Only C:\strawberry\perl\site\lib\Text>sed -n p CSV_XS.pm_LF_Only > CSV_XS.p +m C:\strawberry\perl\site\lib\Text>attrib +r CSV_XS.pm C:\strawberry\perl\site\lib\Text>bytecnt < CSV_XS.pm | egrep "CR|LF" 10 0A LF 1938 13 0D CR 1938 C:\strawberry\perl\site\lib\Text>wc -l CSV_XS.pm 1938 CSV_XS.pm C:\strawberry\perl\site\lib\Text>

      Then I tested it. It resolved the problem.

      C:\>perl -Mopen=:encoding(UTF-8) -MText::CSV_XS -e 1 C:\>perl -MText::CSV_XS -Mopen=:encoding(UTF-8) -e 1 C:\>

      Thank you, ikegami and Tux.

      Jim