[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: regex question
On Tue, Apr 10, 2001 at 01:20:16PM -0700, Robert Threet wrote:
> If I have the following:
>
> while (<DB>) {
> next unless (/(\d{8}).*serial/);
> $oldserial=$1;
> last;
> }
>
> I would've thought this would find the serial number
> in a DNS db file and return it as $1, then break out
> of the loop. It seems to break out of the loop and is
> null. I'm pretty fuzzy on regex and this way of
> breaking out of a loop but I can't think of a better
> way. Does anybody see what I'm doing wrong?
I'm guessing that there's a scope problem there, but am not sure
Why not
while (<DB>) {
/(\d{8}).*serial/;
last if ($oldserial = $1);
}
As a side note, wouldn't it be safer to look for the SOA line, then just
grab the first series of numbers after the "("? (not to mention that I've
got 9-digit serials... :))
--Danny, with nothing better to do than watch the mailing list today
-
To unsubscribe, send email to majordomo@luci.org with
"unsubscribe luci-discuss" in the body.