http://www.perlmonks.org?node_id=967684


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