#!/usr/bin/perl $prev_line = "\n"; while (<>) { chop; $this = $_; # print "DEBUG: original line: $this\n"; if ($prev_line =~ m/^\s+$/) { # don't do anything # print "DEBUG: empty line\n"; $this = "dn: $this"; } else { # replace first token = to first token: # print "DEBUG: full line\n"; ($firsttoken, $remainder) = split (/=/, $this, 2); $this="$firsttoken: $remainder"; } $prev_line = $_; if ($_ =~ m/^$/ ) { print "$_\n"; $prev_line = "\n"; } else { print "$this\n"; } }