Good few rules:
- No, I cannot install Strawberry Perl on this system. I have to use Cygwin.
- This is Perl 5.8.7. I canβt update it.
- This is not my system. This is a customer system, and I cannot modify it in my heart.
Now we have succeeded ...
I installed Spreadsheet::Read , Spreadsheet::ParseExcel and Spreadsheet::XLSX on this system. This installed a little Perl script called xlscat . We did this earlier in the development window and in the UAT box. Now this is a production box.
I get the following error:
Parser for XLSX is not installed at /usr/bin/xlscat line 185
I traced this to Spreadsheet::Read . Relevant Code:
my @parsers = ( [ csv => "Text::CSV_XS" ], [ csv => "Text::CSV_PP" ], # Version 1.05 and up [ csv => "Text::CSV" ], # Version 1.00 and up [ ods => "Spreadsheet::ReadSXC" ], [ sxc => "Spreadsheet::ReadSXC" ], [ xls => "Spreadsheet::ParseExcel" ], [ xlsx => "Spreadsheet::XLSX" ], [ prl => "Spreadsheet::Perl" ], # Helper modules [ ios => "IO::Scalar" ], ); my %can = map { $_->[0] => 0 } @parsers; for (@parsers) { my ($flag, $mod) = @$_; print STDERR qq(DEBUG: Flag = "$flag" Mod = "$mod"\n); $can{$flag} and next; eval "require $mod; \$can{\$flag} = '$mod'"; } print STDERR Dumper(\%can); #DEBUG:
The lines that begin with the line DEBUG: are mine.
A dump of @parsers shows that everything is loaded correctly. The first debug correctly displays the values ββof $flag and $mod .
The problem seems to come from the eval statement. From what I see, it starts require with respect to the module, and then sets the $can{$flag} variable to $mod if it requires success. require Spreadsheet::XLSX seems to fail. Here is the relevant output from my debug instructions:
DEBUG: Flag = "csv" Mod = "Text::CSV_XS" DEBUG: Flag = "csv" Mod = "Text::CSV_PP" DEBUG: Flag = "csv" Mod = "Text::CSV" DEBUG: Flag = "ods" Mod = "Spreadsheet::ReadSXC" DEBUG: Flag = "sxc" Mod = "Spreadsheet::ReadSXC" DEBUG: Flag = "xls" Mod = "Spreadsheet::ParseExcel" DEBUG: Flag = "xlsx" Mod = "Spreadsheet::XLSX" DEBUG: Flag = "prl" Mod = "Spreadsheet::Perl" DEBUG: Flag = "ios" Mod = "IO::Scalar" $VAR1 = { 'csv' => 'Text::CSV_XS', 'sxc' => 0, 'xlsx' => 0, 'xls' => 'Spreadsheet::ParseExcel', 'ios' => 'IO::Scalar', 'prl' => 0, 'ods' => 0 };
Hmmm ... Maybe the module is not installed?
$ perldoc -l Spreadsheet::XLSX /usr/lib/perl5/site_perl/5.8/Spreadsheet/XLSX.pm
It is displayed in perldoc . Let a quick testing program be written:
#! /usr/bin/env perl use Spreadsheet::Read; use Spreadsheet::XLSX; print "It works\n";
A...
$ ./test.pl DEBUG: Flag = "csv" Mod = "Text::CSV_XS" DEBUG: Flag = "csv" Mod = "Text::CSV_PP" DEBUG: Flag = "csv" Mod = "Text::CSV" DEBUG: Flag = "ods" Mod = "Spreadsheet::ReadSXC" DEBUG: Flag = "sxc" Mod = "Spreadsheet::ReadSXC" DEBUG: Flag = "xls" Mod = "Spreadsheet::ParseExcel" DEBUG: Flag = "xlsx" Mod = "Spreadsheet::XLSX" DEBUG: Flag = "prl" Mod = "Spreadsheet::Perl" DEBUG: Flag = "ios" Mod = "IO::Scalar" $VAR1 = { 'csv' => 'Text::CSV_XS', 'sxc' => 0, 'xlsx' => 0, 'xls' => 'Spreadsheet::ParseExcel', 'ios' => 'IO::Scalar', 'prl' => 0, 'ods' => 0 }; It works
I can select Spreadsheet::XLSX through use Spreadsheet::XLSX in my test program, but require in Spreadsheet::Read does not seem to see it.
Why?
Adding
What do you get if you type Dumper (\% INC)? - friedo 2 minutes ago
I really did better. I added the following line in a loop:
require $mod if ($mod eq "Spreadsheet::XLSX");
And this caused an error message:
Can't locate Spreadsheet::XLSX in @INC (@INC contains: /usr/lib/perl5/5.8/cygwin /usr/lib/perl5/5.8 /usr/lib/perl5/site_perl/5.8/cygwin /usr/lib/perl5/site_perl/5.8 /usr/lib/perl5/site_perl/5.8/cygwin /usr/lib/perl5/site_perl/5.8 /usr/lib/perl5/vendor_perl/5.8/cygwin /usr/lib/perl5/vendor_perl/5.8 /usr/lib/perl5/vendor_perl/5.8/cygwin /usr/lib/perl5/vendor_perl/5.8 .) at /usr/lib/perl5/site_perl/5.8/Spreadsheet/Read.pm line 57. Compilation failed in require at ./test.pl line 3. BEGIN failed
( NOTE : I reformatted the output, so it will not contain more than 1000 characters, and it is easier to see the @INC path).
The module is located in /usr/lib/perl5/site_perl/5.8/Spreadsheet/XLSX.pm .
Oh take a look at this too:
$ pwd /usr/lib/perl5/site_perl/5.8/Spreadsheet $ ls -la total 152 drwxr-xr-x+ 4 phalder Domain Users 0 Nov 1 21:51 . drwxrwxrw-+ 11 twinborne Users 0 Nov 1 22:28 .. drwxr-xr-x+ 3 phalder Domain Users 0 Nov 1 20:48 ParseExcel -rwxr-xr-x 1 phalder Domain Users 107773 Apr 6 2011 ParseExcel.pm -rwxrwxrwx 1 phalder Domain Users 29142 Nov 2 12:53 Read.pm drwxr-xr-x+ 2 phalder Domain Users 0 Nov 1 21:51 XLSX -rwxr-xr-x 1 phalder Domain Users 8411 May 16 2010 XLSX.pm $ ls -la XLSX total 48 drwxr-xr-x+ 2 phalder Domain Users 0 Nov 1 21:51 . drwxr-xr-x+ 4 phalder Domain Users 0 Nov 1 21:51 .. -rwxr-xr-x 1 phalder Domain Users 5487 May 16 2010 Fmt2007.pm -rwxr-xr-x 1 phalder Domain Users 37046 May 16 2010 Utility2007.pm
Permissions look fine.
Another application:
When I reinstalled CPAN, I got the following:
Result: PASS /usr/bin/make test -- OK Running make install !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ERROR: Can't create '/usr/lib/perl5/site_perl/5.8/cygwin/auto/Spreadsheet/Read' Do not have write permissions on '/usr/lib/perl5/site_perl/5.8/cygwin/auto/Spreadsheet/Read' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! at -e line 1 Installing /usr/lib/perl5/site_perl/5.8/Spreadsheet/Read.pm Installing /usr/share/man/man3/Spreadsheet.Read.3pm make: *** [pure_site_install] Error 255 /usr/bin/make install -- NOT OK
Oops! I did not check the resolution of the /usr/lib/perl5/site_perl/5.8/cygwin directory tree.
Was chmod -R a+rx * as a whole /usr/lib/perl5 . We will see if it works again.