Looping backreferences
Joshua Goodall
joshua at roughtrade.net
Wed Aug 20 21:27:18 CDT 2003
I have a simple regex for match /24 and /16 reverse lookup domains,
/^(\d+)\.(\d+)\.(?:(\d+)\.)?in-addr\.arpa$/
(it doesn't need to be more precise because the source data is validated)
which I use like this:
$net = join ".", grep { defined } reverse $zone =~ /^(\d+)\.(\d+)\.(?:(\d+)\.)?in-addr\.arpa$/;
thereby turning "1.168.192.in-addr.arpa" into "192.168.1"
and turning "168.192.in-addr.arpa" into "192.168".
Enough background.
I would like (for no other reason than shorter lines and out of curiousity)
to be able to more intuitively write
$net = join ".", reverse $zone =~ /^(?:(\d+)\.){2,3}in-addr\.arpa$/;
but of course this only returns a single backreference, not the three
I'm hoping for when I feed it "3.2.1.in-addr.arpa".
Anyone know if/how it's possible to have a variable-length list returned by
a regex? (preferably 5.6 compat)
J
--
Joshua Goodall "tea makes itself"
joshua at roughtrade.net - Ana Susanj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://mail.pm.org/archives/melbourne-pm/attachments/20030821/a7784dd5/attachment.bin
More information about the Melbourne-pm
mailing list