# Intended for use with VIM as the equalprg # Put the following line in your vimrc or .vim # set equalprg=perl\ d:\utils\equalsprg.pl use strict; use warnings; use Text::Reflow qw/reflow_string/; my $text = join '',<>; exit unless $text; my $enteredvalue= join ' ', map { s/\s*\|\s*/ /g; # remove all pipe chars s/\/\*//g; # remove all block comment-start s/\*\///g; # remove all block comment-end s/^\s*\*//g; # remove all asterisks at start of line s/^\s*\/\///g; # remove all // at start of line s/\-{5,}/ /g; # remove all strings of five or more hyphens $_ } grep {!/^\//} grep {!/^\s*\-+\*\//} split /\n/,$text; exit unless ($enteredvalue); my $maxlen=0; my $result .= join "\n", map{"| " . substr($_ . ' 'x$maxlen, 0, $maxlen) . " |" } map{ $maxlen = length($_) if (length > $maxlen); $_ } # get the max line length split /\n/,reflow_string($enteredvalue); $result = '/*-'.'-'x$maxlen ."\n".$result. "\n" .' '.'-'x$maxlen ."-*/\n"; # top and tail print $result;