Pingu has asked for the wisdom of the Perl Monks concerning the following question:

Good evening.
Pingu is struggling again. His script runs just great on his linux box at home where it was developed, but breaks on his WinNT server where it needs to live.

I'm using Text::xSV and have had to place it in my scripts directory on the server as I don't have access to c:/perl/lib or wherever. So the top of my code looks like:
use lib "f:\\path\\to\\scripts\\"; use strict; use CGI qw(:standard); use Text::xSV; ...
My box at home is fine with this - it just ignores the use lib and carries merrily along.

NT spouts:
Expected ',' at f:\path\to\scripts\my_file.csv, line 1, char 0 at Text +::xSV::_get_row()
This is being called from my script through xSV::bind_header()

The script is the same on both platforms, the file they are reading is identical, I'm confused. see http://www.stragglers.org/cgi-bin/results.pl for the error, http://www.stragglers.org/results.htm for the code

Thankyou again all monks.

Pingu
---

Replies are listed 'Best First'.
Re (tilly) 1: M$/Linux Perl module compatibility problem
by tilly (Archbishop) on Jun 03, 2001 at 05:00 UTC
    That looks rather like pos got reset when I didn't think it would be. Could you either respond here or by email with your version of Perl (perl -v or perl -V) and the contents of the .csv file you are reading? (I will try to debug later tonight.)

    Thanks,
    Ben

      Tilly,

      I see you have altered Text::xSV already, but for the record I'm on perl 5.005_03. Again I am stupended(?) by the great response to all my newbie questions.

      I have made the alteration you suggest in your following post here which resulted in instant success and big smiles all round. Check out the work in progress... Thanks again Tilly,

      Pingu
      ---
Re: M$/Linux Perl module compatibility problem
by bikeNomad (Priest) on Jun 03, 2001 at 04:59 UTC
    A couple of things: first (and not your problem), the argument to 'use lib' doesn't need either backslashes or a trailing slash.

    Second, if you're using the "same file" in both, it may be a difference between the Unix and DOS line endings in text files -- Unix uses a single \x0A character and NT uses \x0D\x0A. But both appear as "\n" to Perl in a text file ON THE APPROPRIATE SYSTEM. However, you could have problems with line endings being different. You could try changing the line endings on the Unix system where it'll be easier to do using recode or a Perl one-liner:

    perl -p -e 'chomp; print "$_\r\n"'
    or in place:
    perl -pi.bak -e 'chomp; print "$_\r\n"'
Re (tilly) 1: M$/Linux Perl module compatibility problem
by tilly (Archbishop) on Jun 03, 2001 at 18:07 UTC
    The bug was mine.

    I have uploaded a new Text::xSV. Alternately you can edit xSV.pm as follows. In _get_row the line that declares $start_field should be:

    my $start_field = qr/\G(")|\G([^"$q_sep]*)/;
    (I had left out one of the \G's and it worked on 5.005_03. A bug hidden by a bug.)

    If that doesn't fix it, please tell me.