in reply to Undefined regexp objects?

For those that wonder how the heck you even can dereference a qr// object: I'm sorry, I don't know either. :)

But this below is usually how I go about when I find an unexpected behaviour of this kind. I perhaps won't get all the whys, but I might get an explanation that works for me and that will add another piece to the puzzle.

I do believe that perl interally treats a qr// as a blessed scalar, being blessed into class Regexp. The object itself is as magical as objects get I think, and we can't get any useful info out of just printing the object as you usually can, but overload can help us out:
use overload; print overload::StrVal(qr/asdf/); # Regexp=SCALAR(...)
And Devel::Peek help us in another way:
use Devel::Peek; Dump(qr/asdf/);
yielding:
SV = RV(0x1af1fd8) at 0x1b0f118 REFCNT = 1 FLAGS = (PADBUSY,PADMY,ROK) RV = 0x1b0f190 SV = PVMG(0x1c2c5ac) at 0x1b0f190 REFCNT = 1 FLAGS = (OBJECT,RMG) IV = 0 NV = 0 PV = 0 MAGIC = 0x1af012c MG_VIRTUAL = 0x2808c138 MG_TYPE = 'r' MG_OBJ = 0x1b0b51c STASH = 0x1de7570 "Regexp"
showing us that regexes are magical. I don't see it being defined anywhere. But I have no idea why this is the case. But I can't say I'd expect a sane dereference value for a magical object. :) In fact, thinking about it I'd more expect undef than anything else because... the value isn't defined since it's not actually a scalar, and what would be a good substitute value anyway?

Hoped this helped in some way,
ihb