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

Hi Monks

I am trying to install and use CPAN's Text::Delimited module in my perl script in UNIX.

Steps that I followed

1. downloaded the module from CPAN site into my local unix directory / +user/comp/name 2. gzip -dc Text-Delimited-2.00.tar.gz 3. tar -xof Text-Delimited-2.00.tar.gz 4. cd Text-Delimited-2.00 5. perl Makefile.PL PREFIX=/user/comp/name 6. make install

This is what i got

cp lib/Text/Delimited.pm blib/lib/Text/Delimited.pm Manifying blib/man3/Text::Delimited.3 Installing /user/comp/name/lib/site_perl/5.8.8/Text/Delimited.pm Installing /user/comp/name/man/man3/Text::Delimited.3 Writing /user/comp/name/lib/site_perl/5.8.8/x86_64-linux-thread-multi/ +auto/Text/Delimited/.packlist Appending installation info to /user/comp/name/lib/5.8.8/x86_64-linux- +thread-multi/perllocal.pod

A lib and man folder was created in the /user/comp/name folder.

my script modtest.pl resides in the /user/comp/name folder.

Here is my script

#!/usr/bin/perl use lib "/user/comp/name"; use strict; use Text::Delimited; my $file = new Text::Delimited; $file->delimiter('\t'); $file->open('file.txt'); my @header = $file->fields; while ( my $row = $file->read ) { print $row->{COLUMN1}; } $file->close;

error: which i get is

Can't locate Text/Delimited.pm in @INC (@INC contains: /user/comp/na +me /opt/nasapps/stow/perl-5.8.8-fixhs/lib/5.8.8/x86_64-linux-thread-m +ulti /opt/nasapps/stow/perl-5.8.8-fixhs/lib/5.8.8 /opt/nasapps/stow/p +erl-5.8.8-fixhs/lib/site_perl/5.8.8/x86_64-linux-thread-multi /opt/na +sapps/stow/perl-5.8.8-fixhs/lib/site_perl/5.8.8 /opt/nasapps/stow/per +l-5.8.8-fixhs/lib/site_perl .) at modtest.pl line 4. BEGIN failed--compilation aborted at modtest.pl line 4.

can someone plz direct me on what is wrong?? how can i install and use the module?? Thanks

Replies are listed 'Best First'.
Re: Usuage of CPAN's Text::Delimited
by ikegami (Patriarch) on Nov 16, 2009 at 23:05 UTC

    You need to add the directory that contains Text/Delimited.pm to @INC. That's not /user/comp/name. I suspect it's /user/comp/name/lib, so

    use lib "/user/comp/name/lib";

    By the way, I prefer the saner

    perl Makefile.PL PREFIX=/some/dir LIB=/some/dir/lib/perl5

    Nowadays, the above can be shortened to:

    perl Makefile.PL INSTALL_BASE=/some/dir

    Specifically, I use

    perl Makefile.PL INSTALL_BASE=~

    Update: Added suggestion for Makefile.PL args.

      I tried both the ways,its gives me the same error.

      use lib "/user/comp/name/lib/site_perl/5.8.8/Text";# This is the path +to the Text/Delimited.pm use lib "/user/comp/name/lib";

      perl Makefile.PL PREFIX=/some/dir LIB=/some/dir/lib/perl5
      In this PREFIX is the local directory path where i want to install the module(which would give me the lib and man folders)

      so does LIB has the path to the LIB folder of the perl? is this correct??

        I believe your first 'use lib' went one directory too far. Try:
        use lib "/user/comp/name/lib/site_perl/5.8.8;
        When you 'use Text::Delimited;', 'Text' is searched for in @INC, then Delimited.pm in 'Text'. Since there is no "/user/comp/name/lib/site_perl/5.8.8/Text/Text", Delimited.pm wasn't found.

        use lib "/user/comp/name/lib/site_perl/5.8.8/Text";# This is the path to the Text/Delimited.pm.

        No, that's the path to Delimited.pm. You want the path to Text/Delimiated.pm. Get rid of that trailing Text