Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Problem with Storable qw(store_fd fd_retrieve)

Reply
Thread Tools

Problem with Storable qw(store_fd fd_retrieve)

 
 
J.D. Baldwin
Guest
Posts: n/a
 
      06-25-2007


Not sure why Storable's sister functions won't talk each other's
language. Here's a stripped down version of what I have:

#!/bin/perl

use strict;
use warnings;

use Storable qw(store_fd fd_retrieve);
use Data:umper;
my $uploaded_ref;

my $TRACKING_DATA_FILE='tracking.dat'; # Does not exist
my $LIST_FILE='biglist.txt'; # 64,109-line text file,
# one token per line

open my $fd, '>', $TRACKING_DATA_FILE;
open my $list_fd, '<', $LIST_FILE;

while ( <$list_fd> )
{
chomp;
$uploaded_ref->{$_} = 1;
}

store_fd($uploaded_ref, $fd);
close $fd;

open $fd, '>>', $TRACKING_DATA_FILE;
my $new_ref = fd_retrieve($fd);

my $numkeys = keys %{$new_ref};
print "Number: $numkeys\n";

This fails with

Magic number checking on storable file failed at blib/lib/Storable.pm
(autosplit into blib/lib/auto/Storable/fd_retrieve.al) line 398,
<$list_fd> line 64109, at ./init.pl line 27

Any ideas what is going on here? I have to use store_fd and
fd_retrieve because of the kind of locking my project requires.

Storable version is 2.16; Perl is 5.8.8.
--
_+_ From the catapult of |If anyone disagrees with any statement I make, I
_|70|___=}- J.D. Baldwin |am quite prepared not only to retract it, but also
\ / http://www.velocityreviews.com/forums/(E-Mail Removed)|to deny under oath that I ever made it. -T. Lehrer
***~~~~-----------------------------------------------------------------------
 
Reply With Quote
 
 
 
 
Martijn Lievaart
Guest
Posts: n/a
 
      06-25-2007
On Mon, 25 Jun 2007 18:49:15 +0000, J.D. Baldwin wrote:

> Not sure why Storable's sister functions won't talk each other's
> language. Here's a stripped down version of what I have:


(snip)

I'm not sure, but...

> open $fd, '>>', $TRACKING_DATA_FILE;


You open $fd for append...

> my $new_ref = fd_retrieve($fd);


.... and try to read from it.
>
> my $numkeys = keys %{$new_ref};
> print "Number: $numkeys\n";
>
> This fails with
>
> Magic number checking on storable file failed at
> blib/lib/Storable.pm
> (autosplit into blib/lib/auto/Storable/fd_retrieve.al) line 398,
> <$list_fd> line 64109, at ./init.pl line 27


As there is nothing to read, the magic number check fails.

HTH,
M4
 
Reply With Quote
 
 
 
 
J.D. Baldwin
Guest
Posts: n/a
 
      06-26-2007

In the previous article, Martijn Lievaart <(E-Mail Removed)> wrote:
> (snip)
>
> I'm not sure, but...
>
> > open $fd, '>>', $TRACKING_DATA_FILE;

>
> You open $fd for append...
>
> > my $new_ref = fd_retrieve($fd);

>
> ... and try to read from it.


Arrrgh. I had '+<' in the original and switched it to '>>' on a
desperation try. Now I'm getting a different error -- I'll try to
boil it down to the smallest postable program snippet and post again.
Thanks.
--
_+_ From the catapult of |If anyone disagrees with any statement I make, I
_|70|___=}- J.D. Baldwin |am quite prepared not only to retract it, but also
\ / (E-Mail Removed)|to deny under oath that I ever made it. -T. Lehrer
***~~~~-----------------------------------------------------------------------
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Storable.pm failing with error Byte order is not compatible at blib/lib/Storable.pm arun Perl Misc 1 03-08-2012 04:18 PM
[BEGINNER]Storable::dclone question soup_or_power@yahoo.com Perl 3 03-29-2005 07:04 PM
Storable - Anyone with experience with this perl mod? Harsha Perl 1 09-11-2004 07:39 PM
Re: Problem with Storable.pm (.xs), Perl 5.8.0, Redhat 9 Daniel Hembree Perl 0 01-12-2004 03:31 AM
Storable module for Activestate 5.6.1?? Kenjis Kaan Perl Misc 3 07-01-2003 04:43 AM



Advertisments