Peter Blair
and 1 contributors


ACL::Regex - Process arbitrary events with regular expressions.


   use ACL::Regex;

   # Instantiate a reject object
   my $reject_acl = ACL::Regex->new->
           generate_required( 'required.txt' )->
           parse_acl_from_file( { Filename => "acl.reject.txt" } );

   while( <> ){
           my ($rc,$regex,$comment) = $reject_acl->match( $_ );
           if( $rc ){
                  print "\t! Rejected against $regex\n";
                  print "\t: Reason: $comment\n";


ACL::Regex allows you to parse a series of actions, key/value pairs through an object containing a series of regular expressions.


The module is written with an object oriented interface. There is no function interface to choose from. To streamline many of the initial operations of the object, many of the initialization methods return the object reference, allowing the programmer to chain the commands together.


This method pulls in a :file containing a series of required keys.


This method re-sorts the keys in alphabetical order.


This method accomplishes the same thing as :sanitize_acl but for actions.


This method takes a hash as a parameter:

  parse_acl_from_file( { Filename => "acl.reject.txt" } )

This method takes an action as a parameter, and returns a triplet containing the return code, matched regex, and any comment associated with the regex.


An example of ain input ACL file can be found in the t folder of this project, but it simply comprises of rows that look like:

  # Don't allow domain admins to delete mailboxes on weekends or mondays
  /action=[mac-delete-mailbox] account=[.*] group=[domain-admin] dow=[sat|sun|mon]/        Domain admins can only delete mailboxes during the week
  # Reject mail from brazil
  /account=[.*] ip=[200..*] group=[user] action=[send-mail]/  No mail to be sent from Brazil!

The two tab deliminated columns separate the regex acl and the comment returned if any match is found.

The required file is supplied to the object during instantiation and will seed the object with a list of required keys in the hash. This way, if a key regex isn't present in the ACL REGEX FILE then the object will fill the hash with a regex that matches all possibilities. This is designed to satisfy the regex string should a key be absent from the action line.

  # This file contains a list of actions, and required attributes

A line of key=[val] pairs to be consumed by the ACL object. These get massaged so that any action key that doesn't satisfy the REQUIRED fields are added and the entire string is sorted by key name.

3 POD Errors

The following errors were encountered while parsing the POD:

Around line 228:

Unknown directive: =head

Around line 241:

Unknown directive: =head

Around line 254:

Unknown directive: =head