我最近将一些Perl代码从SunSolaris迁移到64位的
Linux(Ubuntu)盒子.迁移后Storable.pm突然出现以下错误:
Byte order is not compatible at /usr/lib/perl/5.18/Storable.pm,at /home/VD/Cache.pm line 347.
在互联网上进行一些研究后,我发现我需要使用nfreeze而不是解冻,但现在我收到以下错误:
not a reference at /home/VD/Cache.pm line 347.
有任何建议如何解决这个问题?
sub get { my($self,$type,$param_ref) = @_; #return 1 if(!$self->{'INI'}{'sf.system.cache.enabled'}); if($self->{'INI'}{'sf.system.cache.database.enabled'}) { ### DATABASE my $param = $self->SF::Cache::convert_parameter($type,$param_ref); if($self->SF::Cache::CACHE_TABLE_USERCONTENT && $$param{'type'} == 2) { ### user-content my $query = 'SELECT ParaM_CONTENT AS C,DATA AS D FROM sf_cache_usercontent WHERE SITE=? AND ParaM_USER=?'; my $bindvar = { 1=>$self->{'site'},2=>$$param{'user'} }; my $sth = $self->db_select($query,$bindvar); #print SF::Util::debug_dumpquery($query,$bindvar); return undef if($self->{'Error'}); my %usercontent; undef(%usercontent); while(my $hashref = $self->db_fetch($sth)) { $usercontent{$$hashref{'C'}} = $$hashref{'D'};# ? 1 : 0; } return \%usercontent; } else ### ****************************************************************************************************** { my $ret = $self->SF::Cache::get_database('DATA',$param); return Storable::nfreeze($ret) if(defined $ret); } } else { ### FILESYstem my $filename = $self->SF::Cache::filename($type,$param_ref); if($filename && -e $filename) { if($self->{'INI'}{'sf.system.cache.lock.enabled'} && defined &lock_retrieve) { return lock_retrieve $filename; } else { return retrieve $filename; } } else { $! = 0; } } return undef; }
解决方法
回到你的原始系统,解冻然后冻结那里的文件来修复它.
perl -MStorable=nstore,retrieve -e'nstore(retrieve($ARGV[0]),$ARGV[1])' file fixed