Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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

by mimosinnet (Beadle)
on Apr 27, 2012 at 17:23 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://967684]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (11)
As of 2024-04-18 14:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found