Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^4: Wildcard usage for REMOTE_ADDR comparison

by NetWallah (Abbot)
on Oct 21, 2012 at 14:49 UTC ( #1000221=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Wildcard usage for REMOTE_ADDR comparison
in thread Wildcard usage for REMOTE_ADDR comparison

The "eq" does not work the same as regular expression pattern matching. The latter is much more powerful.

Your question:

what would a wild card for :
if ($ENV{REMOTE_ADDR} eq '180.76.6.') {
is not specific enough. The answer depends on what you want to match against.
For example, to match any digits (actually, between 1 and 3 digits) after the last ".", but require the initial 3 octets to be identical to what is specified, use:
if ($ENV{REMOTE_ADDR} =~/180\.76\.6\.\d{1,3}/) {
My previous post shows a somewhat more flexible regular expression that allows but does not require leading zeros in an octet.

However, as afoken (++) pointed out, this may be too much flexibility if the value you are checking for comes from a "trusted" source, like the CGI module.

             "By three methods we may learn wisdom: First, by reflection, which is noblest; Second, by imitation, which is easiest; and third by experience, which is the bitterest."           -Confucius


Comment on Re^4: Wildcard usage for REMOTE_ADDR comparison
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1000221]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2015-07-30 05:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (270 votes), past polls