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

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

  • Comment on Re^3: Peculiar Error When Loading open Pragma Before Text::CSV_XS Module

Replies are listed 'Best First'.
Re^4: Peculiar Error When Loading open Pragma Before Text::CSV_XS Module
by Tux (Canon) on Dec 24, 2011 at 13:36 UTC

    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

        I changed it like this with just LF's at the end. No CR's. Bottom line is that when using the open pragma (from the command line), the Module source code is read differently and that only Windows has a problem with that.

        If converting LF's to CRLF's "fixes" all these issues on Windows, I can add a note to the documentation, but I'm not going to convert my line endings to CRLF to wipe this problem under the carpet. It is NOT a problem specific to Text::CSV_XS, as the underlying with aforementioned bug shows and it is not going to solve or fix these problems either.


        Enjoy, Have FUN! H.Merijn
Re^4: Peculiar Error When Loading open Pragma Before Text::CSV_XS Module
by Jim (Curate) on Dec 24, 2011 at 20:32 UTC

    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