#!/usr/bin/perl -w use strict; my $node; my $value; my $key2; my $flag=0; my $ORGUNIT="ou=ltspClients2"; my $BASEDN="dc=sludge,dc=net"; my $CREATEBASEENTRIES = "Yes"; #This script is too lame for words, but it miracously works # I decided to go for "magically transmogrifing the input in place" # instead of "read and regurgiate", which is almost surely the saner # more flexible, and extensible way to do it. if($CREATEBASEENTRIES ne "no") { print "dn: $BASEDN\n"; print "objectclass: top\n"; print "\n"; print "dn: $ORGUNIT,$BASEDN\n"; print "objectclass: top\n"; print "\n"; } while(<>) { if(/\[(.*)\]/) { $node=$1; # just so we get valid ldif if($flag gt 0) { print "objectclass: ltspConfig\n"; print "objectclass: ltspXConfig\n"; print "objectclass: ltspPrinterConfig\n"; print "\n"; } print "dn: configName=$node,$ORGUNIT,$BASEDN\n"; print "configName: $node\n"; $flag++; } if(/(.*?)\s*\=\s*(.*)/g) { $key2=$1; $value=$2; $value =~ s/\s//g; $value =~ s/(.*)\#.*/$1/g; $key2 =~ s/\s//g; print lc($key2).": $value\n"; } } print "objectclass: ltspConfig\n"; print "objectclass: ltspXConfig\n"; print "objectclass: ltspPrinterConfig\n";