On Dec 12, 2003, at 4:13 PM, Michael Sullivan wrote:


Michael,

I'm routing this back to the list so that more can share in it.

The gateway IP address for my domain is 68.15.193.18, so could I say:

when you say 'gateway IP address' is this like the address you are issued from an ISP? Hence your WAN side address???

$rem_addr = $ENV{REMOTE_ADDR};
if (rem_addr == '68.15.193.168')
{
        #Do nothing
}
else
{       
        #Add to count
}

Would that work?

not the way you would expect - you're trying to do a numeric compare with between two strings. One of the cool 'reserved words' in Perl is "unless" that functions as 'if not $condition' so you might go with say

$count++ unless ( $rem_addr eq '68.15.193.168');

But I would probably be doing the compare in a
sub so would probably have it as

$count++ unless is_local_host_to_our_domain();

and then down in

        sub is_local_host_to_our_domain
        {
                # fail early if there is no $ENV{REMOTE_ADDR}
                return(0) unless defined($ENV{REMOTE_ADDR});

                $rem_addr = $ENV{REMOTE_ADDR};
                # solve if this is actually inside our domain
                ....

                $retval;
        }

in perl you can get away with just 'asserting' the value
as the last element of a 'sub' rather than

return($retval);

I don't know much about Perl, but if it were C++ it would require some
kind of data type, and I don't know what data type an IP address would
be.  I'd call it a string...

Perl is promiscuous that way.





ciao drieux

---


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to