Re: subroutine call makes foreach exit?
- From: tom@xxxxxxxxxxxxxx (Tom Phoenix)
- Date: Thu, 16 Nov 2006 09:04:53 -0800
On 11/16/06, Andy Greenwood <greenwood.andy@xxxxxxxxx> wrote:
if (/^$domain.+MX\s+(\d+)\s+(.+)/) {
Because $domain is a string (and not a pattern), interpolating it into
a pattern could cause troubles. First, any metacharacters it contains
may affect the match. But also, is that pattern going to mistakenly
find the site "example.com" when the string is actually
"example.com.jp"? These patterns probably need to be crafted a little
more carefully. (If you know your data to be well behaved, this may
not be an issue.)
If I do make the call to getAforMX(), it gets the A records for the
first server, then mysteriously exits the foreach loop which surrounds
the call to getAforMX().
It's not so mysterious when you see what the foreach loop and the
subroutine have in common: @digOut. The sub modified the array while
foreach was still stepping through it. In fact, it's probably a bad
idea for that sub to modify any variables from the surrounding scope;
if that is truly necessary, it should at least be commented.
Cheers!
--Tom Phoenix
Stonehenge Perl Training
.
- References:
- subroutine call makes foreach exit?
- From: Andy Greenwood
- subroutine call makes foreach exit?
- Prev by Date: Re: Perl - Joining of Binary values
- Next by Date: Re: How to 'conditionally' use a specified module
- Previous by thread: Re: subroutine call makes foreach exit?
- Next by thread: Re: subroutine call makes foreach exit?
- Index(es):
Relevant Pages
|