You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Deepak Mallya <ma...@gmail.com> on 2007/04/23 10:17:09 UTC

Error while using Storable.pm for persistent Data Structures from Perl(CGI script)

Hi ,
      I am getting the following error when I use Storable.pm in a CGI
script.Do  I need a different version?Also is there any other package for
using Persistent Data Structures in CGI scripts..I am able to work with
Storable.pm successfully from 2 Perl programs..but when I use a CGI(perl
script)..I cant do so??Can anyone tell me what is wrong?
I actually want to use a complex data structure I built from a large number
of documents so that I can use a web interface to search in the index and
for that I need to  have the data structure in memory for fast access..The
index is around 4 MB... I would appreciate any help


Content-type: text/html Software error:

Storable binary image v2.7 more recent than I am (v2.6) at
../../lib/Storable.pm (autosplit into
../../lib/auto/Storable/_retrieve.al) line 323

Re: Error while using Storable.pm for persistent Data Structures from Perl(CGI script)

Posted by Clinton Gormley <cl...@traveljury.com>.
Deepak - please keep this on list.

On Mon, 2007-04-23 at 05:58 -0500, Deepak Mallya wrote:
> Clinton,
>            That thing worked..but i think there is another problem
> now:)..shud I install this one too?
> 
> Storable object version 2.15 does not match $Storable::VERSION 2.16
> at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/DynaLoader.pm line
> 253.

I think the installation of Storable in your home directory is not
correct - it is looking for the C libraries in the default location, and
not in your local directory.

Are you not able to install Storable 2.16 in the standard system
location? 

If you MUST install it in your home directory, then do something like
the following:

 - Go to your home directory
   cd ~

 - download Storable:
   wget http://search.cpan.org/CPAN/authors/id/A/AM/AMS/Storable-2.16.tar.gz

 - unarchive it:
   tar -xzf Storable-2.16.tar.gz

 - build and install it in your home directory
   cd Storable
   perl Makefile.PL PREFIX=~
   make && make test && make install

This will install it in a directory like this:
  ~/lib/perl5/5.8.8/x86_64-linux-thread-multi/
  eg /home/yourname/lib/perl5/5.8.8/x86_64-linux-thread-multi/

Then use THAT directory in your perl script:
  use lib '/home/yourname/lib/perl5/5.8.8/x86_64-linux-thread-multi/';

Hope this helps

Clint
  
>  
> On 4/23/07, Clinton Gormley <cl...@traveljury.com> wrote: 
>         On Mon, 2007-04-23 at 04:48 -0500, Deepak Mallya wrote:
>         > Clinton,
>         >  I tried it ..It gives me this at the line I added warn. 
>         > Warning: something's wrong at newprocessquery.pl line 24.
>         > Undefined subroutine &main::retrieve called at
>         newprocessquery.pl line
>         > 25.
>         >
>         >  I tried printing @INC after adding the use lib..It gives me
>         the path 
>         > at the front of @INC ..i dont understant y it isnt able to
>         find
>         > Storable.pm when I use retrieve..
>         >
>         
>         
>         Hi Deepak
>         
>         I'm not sure exactly what you are doing in your code, so: 
>         
>         1) I assume that you have successfully managed to use the
>         version of
>         Storable in your home directory to create the file in the
>         first place.
>         
>         In which case:
>         
>         2) Go back to your original CGI script, the one that resulted
>         in the 
>         "can't read v2.7 files" error, and just before the line that
>         gives you
>         that error, add this:
>         
>         use Data::Dumper;
>         warn Dumper(\%INC);
>         
>         in the error log, look for this output, which should include a
>         key 
>         called 'Storable.pm' along with the path to the version of
>         Storable that
>         it is using.
>         
>         My bet is that it is the Storable installed on your system,
>         and not the
>         one in your home directory. 
>         
>         3) So then try this:
>         
>         #!/usr/bin/perl  (or whatever the path to your perl is)
>         
>         use strict;
>         use warnings;
>         
>         use lib '/home/......'; # The path to your version of Storable
>         
>         use Storable; 
>         
>         use Data::Dumper;
>         warn Dumper(\%INC);
>         
>         ----------------------------
>         This should print the new path.
>         
>         4) Having got this working, try it in your main code, just
>         remember only
>         to load the other modules AFTER you have loaded your version
>         of 
>         Storable.
>         
>         
>         
>         
>         >
>         
> 


Re: Error while using Storable.pm for persistent Data Structures from Perl(CGI script)

Posted by Clinton Gormley <cl...@traveljury.com>.
On Mon, 2007-04-23 at 04:48 -0500, Deepak Mallya wrote:
> Clinton,
>  I tried it ..It gives me this at the line I added warn.
> Warning: something's wrong at newprocessquery.pl line 24.
> Undefined subroutine &main::retrieve called at newprocessquery.pl line
> 25.
>  
>  I tried printing @INC after adding the use lib..It gives me the path
> at the front of @INC ..i dont understant y it isnt able to find
> Storable.pm when I use retrieve..
>  


Hi Deepak

I'm not sure exactly what you are doing in your code, so:

1) I assume that you have successfully managed to use the version of
Storable in your home directory to create the file in the first place.

In which case:

2) Go back to your original CGI script, the one that resulted in the
"can't read v2.7 files" error, and just before the line that gives you
that error, add this:

use Data::Dumper;
warn Dumper(\%INC);

in the error log, look for this output, which should include a key
called 'Storable.pm' along with the path to the version of Storable that
it is using.

My bet is that it is the Storable installed on your system, and not the
one in your home directory.

3) So then try this:

#!/usr/bin/perl  (or whatever the path to your perl is)

use strict;
use warnings;

use lib '/home/......'; # The path to your version of Storable

use Storable;

use Data::Dumper;
warn Dumper(\%INC);

----------------------------
This should print the new path.

4) Having got this working, try it in your main code, just remember only
to load the other modules AFTER you have loaded your version of
Storable.




> 


Re: Error while using Storable.pm for persistent Data Structures from Perl(CGI script)

Posted by Deepak Mallya <ma...@gmail.com>.
Clinton,
 I tried it ..It gives me this at the line I added warn.
Warning: something's wrong at newprocessquery.pl line 24.
Undefined subroutine &main::retrieve called at newprocessquery.pl line 25.

 I tried printing @INC after adding the use lib..It gives me the path at the
front of @INC ..i dont understant y it isnt able to find Storable.pm when I
use retrieve..

Deepak

Also I printed @INC after adding

On 4/23/07, Clinton Gormley <cl...@traveljury.com> wrote:
>
>
> > Add this to your CGI script:
> >
> > warn $INC{Storable.pm};
>
> change that to:
> warn $INC{'Storable.pm'};
>
> otherwise it'll break under use strict;
>
> >
> > and I bet you that the path that it prints to your error log is not the
> > one to your home directory.
>
> What you could try doing in this case (I assume you're running it as
> straight CGI and not with Registry or anything similar) is to load
> Storable before you load any other modules.
>
> So :
>
> use strict;
> use warnings;
> use lib '/home/....';
> use Storable;
>
> use Other::Modules...;
> >
> > Clint
> > >
> >
>
>

Re: Error while using Storable.pm for persistent Data Structures from Perl(CGI script)

Posted by Clinton Gormley <cl...@traveljury.com>.
> Add this to your CGI script:
> 
> warn $INC{Storable.pm};

change that to:
  warn $INC{'Storable.pm'};

otherwise it'll break under use strict;

> 
> and I bet you that the path that it prints to your error log is not the
> one to your home directory.

What you could try doing in this case (I assume you're running it as
straight CGI and not with Registry or anything similar) is to load
Storable before you load any other modules.

So :

use strict;
use warnings;
use lib '/home/....';
use Storable;

use Other::Modules...;
> 
> Clint
> > 
> 


Re: Error while using Storable.pm for persistent Data Structures from Perl(CGI script)

Posted by Clinton Gormley <cl...@traveljury.com>.
On Mon, 2007-04-23 at 04:17 -0500, Deepak Mallya wrote:
> Hi,
>     I did install the latest Storable.pm and included using
>     use lib
> "/home/002/d/dp/dpm052000/public_html/cgi-bin/Storable-2.16/blib";
>     I get an error when I use $index=retrieve('filename');
>     Is somehting wrong in the way i am including the library???
>  
> Deepak
> 

Please keep this on list

I think that you're loading a different module which loads Storable
before you have a chance to load yours.

Add this to your CGI script:

warn $INC{Storable.pm};

and I bet you that the path that it prints to your error log is not the
one to your home directory.

Clint
> 


Re: Error while using Storable.pm for persistent Data Structures from Perl(CGI script)

Posted by Clinton Gormley <cl...@traveljury.com>.
>  
>  
> Content-type: text/html 
> Software error:
> Storable binary image v2.7 more recent than I am (v2.6) at ../../lib/Storable.pm (autosplit into ../../lib/auto/Storable/_retrieve.al) line 323
>>From the Storable.pm POD:


files from future versions of Storable
        
        Earlier versions of Storable would immediately croak if they
        encountered a file with a higher internal version number than
        the reading Storable knew about. Internal version numbers are
        increased each time new data types (such as restricted hashes)
        are added to the vocabulary of the file format. This meant that
        a newer Storable module had no way of writing a file readable by
        an older Storable, even if the writer didn't store newer data
        types.
        

You produced the storable file on one machine and are using it on a
different machine?

Firstly, you should upgrade Storable to the latest version (2.16)
http://search.cpan.org/~ams/Storable-2.16/Storable.pm

Secondly, if you are going to use the produced data on more than one
machine, then you should the nstore commands rather than the store
commands.  This guarantees that the file can be read by different
processor types than the originating machine.

For instance, if you were to use store and created the file on a 32 bit
machine, you wouldn't be able to read it on a 64 bit machine.