#! /usr/bin/env perl # $Id: addfolds.pl 794 2007-01-07 22:04:40Z jnieuwen $ use strict ; use warnings ; my @lines ; my $category = '' ; my $oldline = '' ; my $cline = '' ; while (my $line=<>) { $line =~ s/ {{{1//g ; push(@lines,$line) ; } foreach my $line (sort @lines) { $cline = $line ; $cline =~ s/ //g ; next if($oldline eq $cline) ; my ($newcat, $rest) = split(/:/,$line,2) ; if ($newcat ne $category) { chomp $line ; $line .= " {{{1\n" ; $category = $newcat } print $line ; $oldline = $cline ; $oldline =~ s/{{{1//g ; }