in reply to Re^2: WWW::Mechanize clone
in thread WWW::Mechanize clone

At any rate it saved most of it. If you look at the YAML itself you'll see that it didn't get everything, specifically the onerror and onwarn callbacks:

... onerror: !!perl/code: '{ "DUMMY" }' onwarn: !!perl/code: '{ "DUMMY" }' ...

So if you were doing anything special with these handlers you'd want to re-set them ($mech->{onerror} = sub { ... }; there's no API for changing these post-constructor so you've got to break encapsulation) after you've used YAML::LoadFile to read it back in. And I'd still be wary there might be other similar brittleness that I'm not seeing just serializing a brand new, unused instance.

Update: Or try using YAML::Syck instead and set $YAML::Syck::UseCode = 1; however that'll still have problems if the coderefs in question are closures (since the enclosing lexical context is long gone).