use B qw/class svref_2object/; sub is_a_precompiled_regexp { my $r = shift; return 0 unless ref $r; my $o = svref_2object $r; return (class($o) eq "PVMG") && ($o->MAGIC->TYPE eq 'r') ? 1 : 0; }