develooper Front page | perl.perl5.porters | Postings from March 2007

[PATCH] Alter the package qr// gets blessed into via a pragma

Thread Next
Ævar Arnfjörð Bjarmason
March 20, 2007 13:12
[PATCH] Alter the package qr// gets blessed into via a pragma
Message ID:
All regular expressions constructed with qr// are currently blessed
into the "Regexp" package. This can be altered on a per-regexp basis
by doing:

my $re = bless qr/Ponies/ => "My::Regexp";

But there's no way to alter the default.

The attached patch allows for specifying what package regular
expressions are blessed into by setting a package name in $^H{regobj},
this would allow for writing extensions like the attached
re::object::Test (which does nothing at the moment except retrieve the
regexp struct from the object).

Whether or not applying this is a good idea depends largely on the
efficiency of looking up things in the hints hash. There's already
such a lookup in pp_regcomp.

If list members think that this should be applied I'll submit a
documentation patch as well.

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About