Skip to content

Instantly share code, notes, and snippets.

@blaxter
Created March 23, 2015 16:47
Show Gist options
  • Save blaxter/60ef4836f341df0cd183 to your computer and use it in GitHub Desktop.
Save blaxter/60ef4836f341df0cd183 to your computer and use it in GitHub Desktop.
ldap filter pretty print
#! perl -slw
use strict;
( my $input = do{ local $/; <DATA> } ) =~ tr[\n][]d;
my $tab = 0;
$input =~ s[([()])]{
$tab-- if $1 eq ')';
my $modified = "\n" . ( " " x $tab ) . $1;
$tab++ if $1 eq '(';
$modified;
}ge;
$input =~ s[\n\s+\)][)]g;
print $input;
__DATA__
(& (mailnickname=*) (| (&(objectCategory=person)(objectClass=
user)(!(homeMDB=*))(!(msExchHomeServerName=*)))(&(objectCategory=person)(obje
ctClass=user)(|(homeMDB=*)(msExchHomeServerName=*)))(&(objectCategory=person)
(objectClass=contact))(objectCategory=group)(objectCategory=publicFolder)(obj
ectCategory=msExchDynamicDistributionList) ))
@blaxter
Copy link
Author

blaxter commented Mar 23, 2015

ez

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment