Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
"be consistent"
 
PerlMonks  

Re^6: Create a ipset for blocking networks based on internet sources

by mimosinnet (Sexton)
on Apr 27, 2012 at 17:23 UTC ( #967684=note: print w/ replies, xml ) Need Help??


in reply to Re^5: Create a ipset for blocking networks based on internet sources
in thread Create a ipset for blocking networks based on internet sources

Thanks for the tip on the use of the extended pattern (?: ) to not make backreferences!

It has been also very enlightening to see the relationship between the foreach loop and the $_ variable, and what would be the equivalent of the while loop and the $1 bakcreference.

Your second suggestion has made me explore more how the while loop works, realizing that while ( $response->content =~ /$regex/g ) gets the content each time that the loop is called. I have changed it by:

my $resp = $response->content; while ( $resp =~ /$regex/g ) { @sys = (qw(ipset add), "temp_$set_name", $1); }

Your comments have been very useful! Although all these issues are on the documentation, it is sometimes difficult at the beginning to find the right section at the right time. It has been great to apply it to a specific example. Very greatful!

Cheers!


Comment on Re^6: Create a ipset for blocking networks based on internet sources
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2014-04-21 12:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (495 votes), past polls