in reply to Split file
You can modify $/ ( the Perl new line delimiter ) to ..DN: and then slurp each record in as one thing.
#!/usr/bin/perl $/ = '..DN'; while(<DATA>){ chomp; if($output =~ m/\.\.DN:(.*)/) { open($fh, '>', "$1.xml") or die "$1.xml: $!"; print $fh, $_; } # End of sub sroutine } [download]