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

I am having fun with modules. The web server I am attempting this on does not have the correct module installed (DBD::CSV), the admin won't install it for me and I have no telnet access to the machine. So, I created a lib directory in the root of the web server and placed the CSV.pm and File.pm in a DBD directory. I am calling it thusly:

1: #!/usr/bin/perl
2: 
3: use lib '/home/user/www/lib';
4: use DBD::CSV;
5: 
6: exit;

using the handy web server verbose check_perl util, I get this error.

Illegal character \015 (carriage return) at /home/user/www/lib/DBD/CSV.pm line 1.
(Maybe you didn't strip carriage returns after a network transfer?)
BEGIN failed--compilation aborted at /home/user/www/test.pl line 4.

I know for a fact that the carraige returns are not the problem, because I have tried this with numerous modules, all giving me the same error. The line number (for the "illegal carraige return") will always be the line immediately preceding the first line of uncommented code.

As you can see, I am thoroughly confused. I may be missing something blatently obvious, but any help would be appreciated.

Replies are listed 'Best First'.
Re: Modules
by chromatic (Archbishop) on Jul 24, 2000 at 08:58 UTC
    Did you download these modules in tarballs (.tar.gz files) or as straight .pm files?

    If the latter, it's possible that they were converted to use DOS-style line endings of \r\n. If you open the files in vi, you might see the nasty ^M character. If so, see Remove the ^M Character from a Document. This could also happen if you transferred them from a DOS-type box to a Unix machine over the network or on a floppy.

    If you're using FTP to transfer them, be sure to use ASCII mode for automatic line conversion.

    If not... I'm sure confused. :)

      Note that if vi in your system is actually vim, you won't see the ^M characters displayed. Vim sees the \r\n line endings and opens up the file in dos format, wherein it silently preserves the dos line endings. It will show this when it starts up as part of displaying the file name, line and character counts:
      "foo" [dos] 3L, 9C
      To have vim strip the ^M characters for you, change the file format to "unix" as follows:
      :set ff=unix
Re: Modules
by davorg (Chancellor) on Jul 24, 2000 at 13:06 UTC

    The fact that you're getting the same error for all of the modules that you've uploaded would strongly imply to me that the carriage returns are the problem. I'm betting that you're unzipping the modules on a Win32 machine and then uploading them to a Unix machine using some kind of binary file transfer. As chromatic points out, you should transfer the files in ASCII mode.

    You might find that this article explains the problem in a bit more detail.

    --
    <http://www.dave.org.uk>

    European Perl Conference - Sept 22/24 2000, ICA, London
    <http://www.yapc.org/Europe/>