Howdy!

I upgraded Storable on an old app and started to get this error from
Storable:

Can't store REGEXP items at ...


Turns out the ORM we have is setting a DateTime::Format::Strptime formatter
on the DateTime objects and the formatter has a regex for the parser.

This happens as they are "inflated" from the DB,  Some of these are later
cached which triggers the error.

Should or can the formatter have a Storable hook to remove the parser?
Any suggestions on an easy workaround?

Granted, it's questionable putting the formatter on the DateTime objects
when pulled from the database instead of in, say, a view.   But removing it
now would mean hunting down all the places where the DateTime objects are
rendered for display.


use strict;
use warnings;
use DateTime;
use Storable 'nfreeze';
use DateTime::Format::Strptime;

my $dt = DateTime->now;

my $format = DateTime::Format::Strptime->new(
    pattern => '%x %X',
    locale  => 'en_us' );

$dt->set_formatter( $format );
nfreeze( $dt );



-- 
Bill Moseley
mose...@hank.org

Reply via email to