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

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

Thread Next
From:
Ævar Arnfjörð Bjarmason
Date:
March 20, 2007 13:12
Subject:
[PATCH] Alter the package qr// gets blessed into via a pragma
Message ID:
51dd1af80703201311w4482d669la9274baa592f0b97@mail.gmail.com
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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About