CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: General Discussions: General Questions:
how to fix "Can't locate Scalar/Util.pm in @INC" error

 



iavian
Novice

Nov 18, 2007, 2:10 PM

Post #1 of 8 (10921 views)
how to fix "Can't locate Scalar/Util.pm in @INC" error Can't Post

Hi, I'm new to this forum. I hope i will get help for the below error. I am getting the below error when i try to use the ParseExcel module in Perl.
=============================
Perl version i use:
=============================
Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration:
Platform:
osname=solaris, osvers=2.8, archname=sun4-solaris
uname='sunos solaris 5.8 generic sun4u sparc sunw,ultra-5_10 '
...
...
...
Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration:
Platform:
osname=solaris, osvers=2.8, archname=sun4-solaris
uname='sunos solaris 5.8 generic sun4u sparc sunw,ultra-5_10 '
============================
Installed modules
============================
Perl -- 5.6.1
Spreadsheet::ParseExcel -- 0.32
============================
my perl script:
============================
#!/usr/local/bin/perl
use Spreadsheet::ParseExcel;
my $file="test1.xls";
my $excel = Spreadsheet::ParseExcel::Workbook->Parse($file);
=====================================
I'm getting below error when I say perl test_parse_excel.pl
=====================================
Can't locate Scalar/Util.pm in @INC (@INC contains: /usr/local/lib/perl5/5.6.1/sun4-solaris /usr/local/lib/perl5/5.6.1 /usr/local/lib/perl5/site_perl/5.6.1/sun4-solaris /usr/local/lib/perl5/site_perl/5.6.1 /usr/local/lib/perl5/site_perl .) at /usr/local/lib/perl5/site_perl/5.6.1/Spreadsheet/ParseExcel.pm line 67.
BEGIN failed--compilation aborted at /usr/local/lib/perl5/site_perl/5.6.1/Spreadsheet/ParseExcel.pm line 67.
Compilation failed in require at test_parse_excel.pl line 3.
BEGIN failed--compilation aborted at test_parse_excel.pl line 3.




Any help is appriciated.


Regards and thanks in advance.


KevinR
Veteran


Nov 18, 2007, 3:05 PM

Post #2 of 8 (10920 views)
Re: [iavian] how to fix "Can't locate Scalar/Util.pm in @INC" error [In reply to] Can't Post

Looks like you need to install Scalar::Util

http://www.cpan.org/misc/cpan-faq.html#How_install_Perl_modules
-------------------------------------------------


iavian
Novice

Jan 25, 2008, 11:44 AM

Post #3 of 8 (10820 views)
Use of uninitialized value in string eq at /usr/local/lib/perl5/site_perl/5.6.1/Spreadsheet/ParseExcel.pm line 310 [In reply to] Can't Post

Hi,
I need to read an excel file so installed Spreadsheet::ParseExcel and installed dependency modules aswell. When I try to parse the excel file i am getting below

Use of uninitialized value in string eq at /usr/local/lib/perl5/site_perl/5.6.1/Spreadsheet/ParseExcel.pm line 310.

The code that i have in my perl file is as below(Just 3 lines of code):

#!/usr/bin/perl
use Spreadsheet::ParseExcel;
my $Excel = new Spreadsheet::ParseExcel;



Any help is appreciated.


Iavian


KevinR
Veteran


Jan 25, 2008, 12:44 PM

Post #4 of 8 (10819 views)
Re: [iavian] Use of uninitialized value in string eq at /usr/local/lib/perl5/site_perl/5.6.1/Spreadsheet/ParseExcel.pm line 310 [In reply to] Can't Post

The error (a warning really) is coming from the ParseExcel module. Evidently a variable being processed by the module has no value when used with the string operator "eq" and the warning gets displayed. Sometimes warnings are inevitable but cause no problems, sometimes they alert you to a situation that needs fixing. No way to tell from what you have posted.
-------------------------------------------------


iavian
Novice

Jan 25, 2008, 1:25 PM

Post #5 of 8 (10818 views)
Re: [KevinR] Use of uninitialized value in string eq at /usr/local/lib/perl5/site_perl/5.6.1/Spreadsheet/ParseExcel.pm line 310 [In reply to] Can't Post

Hi Kevin,
Greetings!

Below is the full error what i get and my full program aswell.
I think its a error not a warning message because i dont get any output.

my program code as below(test_parse_excel.pl):
-------------------------------
#!/usr/bin/perl
use Spreadsheet::ParseExcel;

my $Excel = new Spreadsheet::ParseExcel;
die "Please provide a excel filename to be parsed " unless @ARGV;
my $file = $ARGV[0];
my $var1;

my $WorkBook = $Excel->Parse($file);
$WorkSheet1 = $WorkBook->{Worksheet}[0];



if( defined $WorkSheet1->{Cells}[1][1] )
{
$var1 = $WorkSheet1->{Cells}[1][1]->Value;
}

print "Data from excel with value: ".$var1;


error when i execute as below:
----------------------------------
/export/home/iavian/ >perl test_parse_excel.pl test.xls
Use of uninitialized value in string eq at /usr/local/lib/perl5/site_perl/5.6.1/Spreadsheet/ParseExcel.pm line 310.
Can't call method "numify" without a package or object reference at /usr/local/lib/perl5/site_perl/5.6.1/OLE/Storage_Lite.pm line 1329.


test.xls is a microsoft excel file created in version Excel2000.



KevinR
Veteran


Jan 25, 2008, 4:06 PM

Post #6 of 8 (10811 views)
Re: [iavian] Use of uninitialized value in string eq at /usr/local/lib/perl5/site_perl/5.6.1/Spreadsheet/ParseExcel.pm line 310 [In reply to] Can't Post

I can't tell by looking at your code, you can see those warnings are coming from the modules your script uses, not from your script, and they are warnings, not errors. I hve never used the Spreadsheet::ParseExcel module so I have no idea how good it is or how to use it. Are you passing a valid filename into the script on the command line? Try just this for right now:


Code
#!/usr/bin/perl 
use Spreadsheet::ParseExcel;

my $Excel = new Spreadsheet::ParseExcel;
die "Please provide a excel filename to be parsed " unless @ARGV;
my $file = $ARGV[0];
print $file;


and see if it will print the filename you pass it.
-------------------------------------------------


Kanji
User

Feb 2, 2008, 6:49 PM

Post #7 of 8 (10792 views)
Re: [iavian] Use of uninitialized value in string eq at /usr/local/lib/perl5/site_perl/5.6.1/Spreadsheet/ParseExcel.pm line 310 [In reply to] Can't Post


Quote
Use of uninitialized value in string eq at /usr/local/lib/perl5/site_perl/5.6.1/Spreadsheet/ParseExcel.pm line 310.


This is a known bug in S::PE, and one that I submitted a patch for 6mos ago:-


Code
--- ParseExcel.pm      Thu Aug 16 14:31:07 2007 
+++ ParseExcel.pm Thu Aug 16 14:32:50 2007
@@ -307,7 +307,7 @@
my ($class, %hParam) =@_;

if (not defined $_use_perlio) {
- if (exists $Config{useperlio} && $Config{useperlio} eq "define") {
+ if (exists $Config{useperlio} && defined $Config{useperlio} && $Config{useperlio} eq "define") {
$_use_perlio = 1;
} else {
$_use_perlio = 0;


If you're not familiar with applying patches, this one is simple enough to make by editing S::PE directly, changing the existing line 310 (prefixed with a - above) to a fixed version (prefixed with a +).
--k.


KevinR
Veteran


Feb 3, 2008, 11:45 AM

Post #8 of 8 (10791 views)
Re: [Kanji] Use of uninitialized value in string eq at /usr/local/lib/perl5/site_perl/5.6.1/Spreadsheet/ParseExcel.pm line 310 [In reply to] Can't Post

Can't get a better answer than that Cool
-------------------------------------------------

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives