On Mon, Jan 14, 2002 at 07:32:15PM -0500, Aaron D. Marasco wrote: > > Here is my attempt, at 7 lines (need to count #! line)... > > #!/cygdrive/r/perl/bin/perl -n > if(/[\s-]*([^:]*)\s*:/){$a[$.]="--== $1 ==--\n";next} > ($a[$.],$b[$.],$c[$.])=/\s+(\w+)\s*(\w*)\s*(\d*)/; > $l=length$1;$m=$l if($l>$m); > END{foreach$i(1..$.){$r=$a[$i];print$r;if($r!~/=/){ > print" "x($m-length$r)." : $b[$i] std_logic"; > print (($c[$i]!='')?"_vector($c[$i] downto 0);\n":"\n")}}}
I think this works: -- SUN: -- S_RSTb out -- S_INTb in -- CMX INTERFACE: -- CMX_CSb in -- CMX_D inout 7 -- CMX_A inout 7 #! perl # run with perl -x open 0;while(<0>){last if/^#/;s|\s*--\s+(.*):|--== $1 ==--||| s&\s*--\s*(\w+)\s+(\w+)\s+(\d*)\s*&"$1: $2 std_logic". ($3?"_vector($3 downto 0)":'').";\n"&e&&$l>length$1or$l=length$1; $\.=$_}END{$_='';$\=~s/(.*):/$1.' 'x($l-length$1).' :'/ge;print} Joy, `/anick -- The whole secret of life is to be interested in one thing profoundly and in a thousand other things well. - Hugh Walpole