I am caching menus in a plugin ... but sometimes the menu contains a code reference in style:
Code:
$menu->{type} = 'link';
$menu->{url} = \&getMoreData;


sub getMoreData{

etc etc

}
If I try to cache this then it fails because of the code reference - with an error something like
Code:
Can't store CODE items at /usr/local/lib/perl5/5.32.0/arm-linux-gnueabihf-thread-multi-64int/Storable.pm line 370, at /usr/local/slimserver/Slim/Utils/DbCache.pm line 69.
I understand the reason, but how can I test for the presence of that reference in style "\&getMoreData;" before I try to cache it so that I don't try to cache it.
Of course, I could set a flag to say that there is a code reference when I put it in there and then check for it but am after a more generic solution.
However, the menu structure code be deep and the problem could be some levels down and would be easy to make a mistake.

From the code in Storable.pm it looks like I have to do an "eval" and trap it - but it would help if someone could explain it a bit.
Code:
 # Call C routine mstore or net_mstore, depending on network order
    eval { $ret = &$xsptr($self) };
    if ($@) {
        $@ =~ s/\.?\n$/,/ unless ref $@;
        logcroak $@;
    }
    $@ = $da;