print <) { # get rid of annoying tabs and \n chomp; s/^\s*//; # name this entry $thisentry= $_; # give it an id $id{$thisentry}= ++$idcount; # remove last sub-category s/,?[^,]+$//; # set the parent $parent{$thisentry}=$id{$_}+0; # print printf "| %2d | %-18s | %6d |\n", $id{$thisentry}, $thisentry, $parent{$thisentry}; } print <