Hello,
I have a problem while using CGI::Session, when I try to store an object. After a few tests, I've isolated the problem.
I have got a class (Md), which contains a method param().
When I dump (data::Dumper) an object of this class, when I 'thaw' it with Safe (which basically do sandbox'ed eval), I get an object from the right class, but which can not execute param();
See following code for explanation:
#!/usr/bin/perl use strict; use Data::Dumper; use Safe; package Md; sub new {bless {'plop' => 'coin'}, $_[0]}; sub param {return $_[0]->{$_[1]};} package main; #Object and dump creation my $md = Md->new(); my $dump = Dumper($md); #'eval'ed dump my $mde = eval($dump); print defined $mde ? "Defined" : "undef"; # => print undef, bad #Dump 'Safe' eval my $mdr = Safe->new->reval( $dump ); print defined $mdr ? "Defined" : "undef"; # => print defined, good print $mdr->can('param') ? "yes" : "No"; # => print No. Why?
Why a Md object ($mdr) cannot execute one of the Md methods?
Notes:
I noticed that by using $Data::Dumper::Terse or without 'use strict' it is possible to restore the object as intended, but the problem is hidden inside CGI::Session, I thus cannot use these solutions.
Thanks for you help
In reply to CGI::Session cannot read data from Data::Dumper by lom
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |