#!/usr/bin/perl #!/usr/local/bin/perl # # tabla (for TABLeau Ascii) # use File::Copy; use strict; # # some constants # my $printhelp = 0; my $nom = "tabla"; my $lala; my $ver = "0.80 (2003/01/05)"; my $sig = $nom." ".$ver; my $avant = "<"x25; my $apres = ">"x25; my $bandeau = $avant." ".$sig." ".$apres."\n"; my ($jou,$moi,$ann) = (localtime)[3,4,5]; $moi++; $ann = $ann + 1900; my $dat = $ann."/".$moi."/".$jou; my $log = "tabla.log"; my %argu = (); my @argu; my @lar = (); my $la; my $lla; my $lnu; my $hl; my $nbc; my $jbd; my $jd; my $sd; my $yd; my $hd; my $hdd; my $larg; my $nbcl; my $element; my $numlig; my $numcol; my $fentree; my $fsortie; my $nbae; my $nbaef; my $k; my $v; my $defdef; my %defdef; my @defdef; my %or; my $nbr; my $para; my @ARGU; ############################################# # # beginning mini help pages # my %aide = (); $aide{A} = "Introduction $sig produces a formatted table from a simple ascii file. The ascii file is similar to those produced by commom softwares when exporting in \"txt\" mode. The main rule is one file record by one table line, each cell value {column/field} separated by a separator. The output formats are: ascii: \"txt\", html: \"html\", latex: \"tex\", input file: \"tt\". Four styles of output can be used (except for the \"input file\" format). 0: \"table\", 1: \"bullet list\", 2: \"definition list\", 3: \"label structure\". Various parameters (or instructions inserted into the proper input file) allows some useful possibilities. "; $aide{B} = "Structure of the input file (*) The records of the input file starting with \"#\" (or whatever you prefer according to your parameters, with the parameter \"com\") are not considered by tabla. (*) the records of the input file starting with \":TABLA:\" (default, can also be changed by argument \"ins\") are supposed to be instructions for the formatting of the output table. The four next characters indicates the instructions, next are possible arguments. (*) space characters next to separators can be excluded from the field (default=yes; argument = \"bla\"nk). (*) empty fields are obtained by two successive separators. (*) the number of columns of the resulting table is the maximum number of fields of all input records. When a record does not have this number of fields, its last fields are considered as empty. "; $aide{C} = "Parameters (1): a first touch Most options are indicated through parameters : all of them have default values. They can be changed either by inline arguments or file parameters or insertion in the input file. If a parameter is defined several times, then the last definition is the used definition within each possibilities, and following the (default values,parameter file, inline, data file) order. "; $aide{D} = "Parameters (2): inline parameters (including HELP) Two cases must be distinguished (i) asking help or (ii) transforming a table (i) asking help \"tabla\" provides the table of contents with numbering \"tabla -h G\" provides the chapter \"G\" and so on \"tabla -h all\" provides all chapters (for instance for printing) \"tabla -h par\" provides the list of all \"inline\" parameters \"tabla -h par titi\" provides details only on parameter \"titi\" \"tabla -h par all\" provides details on all \"inline\" parameters These options are not available through the \"parameter file\"! (ii) transforming a table \"tabla \" is a collection of even numbered arguments like '-ins command -com \"this line is a comment\" -sorows 3' that is pairs are on model \"-type value\", hyphen is compulsory even if redundant with the position of the argument. is just the [path]name of the input file (wild card are not admitted) notice that under MSW, you must add \"perl \" before \"tabla...\". "; $aide{E} = "Parameters (3): defined inside the parameter file parameters defined inside the parameter file follow the same syntax that inline parameters except that (or \"\\n\") are equivalent to blank characters and lines beginning with a \"#\" are not taken into account. notice that \"#\" cannot be replaced by another value conversely to the data file. be careful, an empty line is necessary at the end of this file if not a bad number of arguments will be detected. remark: the log file is a valid parameter file "; $aide{F} = "Parameters (4): defined inside the input file NOT YET IMPLEMENTED... IN NEXT VERSION PERHAPS The :TABLA: instructions have always priority on the parameters defined by argument at calling. \":TABLA:\" can modify inline parameters. \":TABLA:sepa\" defines the separator. For instance the default separator would be indicated by \":TABLA:sepa ;;\". The separator can be modified such that the separator be different for different parts of the data table. \":TABLA:typo\" defines (if consistent with the type output) some typographical points. The printing of each columns can be (\"n\"ormal or \"b\"ol\" or \"i\"talic) and (\"n\"ormal or \"l\"ower case or \"u\"pper case). A final possibility is the size of the font to use : 5 is the normal size, 4 is a reduced size, 6 is a magnified size and so on according to the output type. Now these modifications can be applied to the one following line (default) or to a given number of lines (\"*\" means every following lines) indicated into parenthesis. Just to give an example : \":TABLA:typo (5) il 6bu bu bu\" will applied for the following 5 lines, \"italic and lower case\" to the first column, \"magnyfied and bold and upper case\" to the second column, and \"bold and upper case\" to the next two columns and, if any, no modification to the remaining columns. \":TABLA:srow\" defines a modification of the order of the lines sorting them according to a given column. The sorting can be numeric or lexicographical (default). To define the instruction by an example \":TABLA:srow (3) 5n\" will sort the three next record according to the fifth column numerically. \":TABLA:scol\" defines a new order for ALL the columns. The sorting is applied whereever is the instruction. Either the order is defined through the sorting of a named row : \":TABLA:scol 3n\" indicates to use numerically the third row, or giving directly the order \":TABLA:scol 3 5 1 4 1\" indicates that the input third column will be put as first in the output and so on... If not all columns are indicated, the non indicated are put in their order at the end. "; $aide{G} = "Some Examples (1) [perl ]tabla data.txt transforms the data.txt file with all defaults except those given in itself (2) [perl ]tabla -h par displays the types and possible values for \"inline parameters\" (3) [perl ]tabla -h par sorows displays the comment associated to \"sorows\" parameter (4) [perl ]tabla -sepa ; -sorows 1N -o html blup transforms the blup table - according to separator \";\" - sorting the rows according to column 1 - producing a latex file name \"blup.tex\" "; $aide{H} = "Log file When transforming a table, tabla produces a log file in which are put all details concerning what it is doing (see an example). This file is written such that it is a valid future \"parameter file\". The default name is \"$log\" but can be changed by parameter Nevertheless a \"$log\" is firstly created and then the name is changed to yours. So if such a file preexists, it is ALWAYS destroyed (protection seems of no value). "; $aide{I} = "Further planned improvements (*) finish the \"t3\" output with the automatic numbering (*) implement \"parameter (4)\" section (*) deal consistently with possible subcolumns defined by a sub-separator (*) allow the possibility of gathering some columns together [e.g. to form \"M. John Gower\" in a single cell] "; $aide{J} = "Error to be corrected (*) ... "; $aide{K} = "More details (*) All spaces around the separators are eliminated except if you use the \"bla\" parameter (*) The specific \"tt\" output format: This quite specific output was created to allow successive transformations of the input file before obtaining the desired formated output. For instance you want to perform simultaneously a selection of the rows from two differents columns... Remarks: (+) comments are definitively lost (+) title is preserved if it exists (+) \"seplist\" string is used as separator so if you want to use \"sepa\" you need to force it by yourself (*) To obtain a definition of the list not in first column you can use the \"socols\" parameter "; $aide{L} = "Conclusion Any suggestion, reaction, comment are welcome, thanks to send them to \"jbdenis\@jouy.inra.fr\". "; # # ending mini help pages # ############################################# ############################################# # # beginning parameter definitions # ### when the possible values of a parameter are restricted then ### the hash whose name is the parameter name gives ### - by its keys the list of possible values ### - by its values the explanation of the values ### - by the value of compulsory key "default" the default value ### ### when the possible values of a parameter are free: such a hash ### have no more than the default component ### ### %parameters gives the list of possible parameters ### ### no further comments because all is included in the code my %parameters = (); $parameters{pf} = "name of the parameter file; 0 means there is no"; my %pf = (); $pf{default} = 0; $parameters{bla} = "can spaces around separators be eliminated?"; my %bla = (); $bla{default} = "y"; $bla{y} = "spaces around separators can be eliminated"; $bla{n} = "spaces around separators cannot be eliminated"; $parameters{o} = "type of the output file to produce"; my %o = (); $o{default} = "h0"; $o{h0} = "html output file with table"; $o{l0} = "latex output file with table"; $o{t0} = "text output file with table"; $o{h1} = "html output file with bullet list"; $o{l1} = "latex output file with bullet list"; $o{t1} = "text output file with bullet list"; $o{h2} = "html output file with definition list"; $o{l2} = "latex output file with definition list"; $o{t2} = "text output file with definition list"; $o{h3} = "html output file with label structure"; $o{l3} = "latex output file with label structure"; $o{t3} = "text output file with label structure"; $o{tt} = "text following input structure [see chapter K]"; $parameters{i} = "type of the input file which is transformed"; my %i = (); $i{default} = "t"; $i{h} = "html input file with table (not yet available)"; $i{l} = "latex input file with table (not yet available)"; $i{t} = "text input file "; $parameters{nm} = "name of the output file; 0 means constructed from the input file with standard suffix"; my %nm = (); $nm{default} = 0; $parameters{serows} = "indicates which rows must be selected with two possibles ways, either indicating the selected row number or selecting through a matching criterion onto the value of a given column. In the first case, provide a series of numbers separated by \"/\" like \"/3/1/4/\". Two important points : (i) the numbering is this of the input file, i.e. including \"no data lines\" as are the comment lines and parameter lines, and also the possible title line in first position; (ii) whatever is the order of the numbers, the orginal order is preserved so \"/3/1/4/\" is identical to \"/1/3/4/\" or \"/3/1/4/3/\". In the second case, a regular *Perl* expression is furnished preceded by the number of the column to apply: \"5/but/\" means select only rows the fifth column of which contains the character string \"but\". \"5\"/^T/\" means select only rows such that the fifth column contains \"T\" in first position... Note.1 that this columns need not to be selected Note.2 some special characters can cause trouble (\"@\" and \"$\" were corected but other may be troubleful) see subroutine selecrow. \"0\" or non consistent syntax implies no selection. "; my %serows = (); $serows{default} = 0; $parameters{sorows} = "sorting or ordering the rows : - 0 means all rows are displayed in the input file order - a positive number followed by \"A\", \"a\", \"N\" or \"n\" indicates the column number from which a sorting must be performed : \"A\" : increasing alphabetical sorting \"a\" : decreasing alphabetical sorting \"N\" : increasing numerical sorting \"n\" : decreasing numerical sorting for instance \"6N\" implies sorting in increasing numerical order according to column number 6. - a series of numbers separated by \"/\" indicates the order to adopt with possible repetitions and missings. Syntax is \"/3/1/4/3/\" Note: this is done AFTER that \"serows\" parameter operation has been performed, so the numbering of rows may be not this of the input file. "; my %sorows = (); $sorows{default} = 0; $parameters{reprow} = "repeating the firt row - 0 means no repeating - \"n\" means repeating the first row every n rows, that is inserting in between \"n\" and \"n+1\", and \"2*n\" and \"2*n+1\" and so on until reaching the end of the file. Note: this is done AFTER that \"serows\" and \"sorows\" has been performed, so the numbering of rows may be not this of the input file. "; my %reprow = (); $reprow{default} = 0; $parameters{number} = "numbering the rows - 0 means no numbering - \"n\" positive means numbering in an additional \"n\"th column/field << not yet implemented in case of \"t3\" output! >> "; my %number = (); $number{default} = 0; $parameters{socols} = "sorting and ordering the columns : identical to \"sorows\" (permuting the role of rows and columns) "; my %socols = (); $socols{default} = 0; $parameters{brow} = "number of the row/record to be bolded; \"0\" means no bolding the numbering is applied before any sorting"; my %brow = (); $brow{default} = 1; $parameters{irow} = "number of the row to be italicized; \"0\" means no one the numbering is applied before any sorting"; my %irow = (); $irow{default} = 0; $parameters{bcol} = "number of the column/field to be bolded; \"0\" means no bolding the numbering is applied before any sorting"; my %bcol = (); $bcol{default} = 0; $parameters{icol} = "number of the column/field to be italicized; \"0\" means no one the numbering is applied before any sorting"; my %icol = (); $icol{default} = 0; $parameters{urow} = "number of the row/record to be upper cased; \"0\" means no upper casing the numbering is applied before any sorting"; my %urow = (); $urow{default} = 0; $parameters{ucol} = "number of the column/field to be upper cased; \"0\" means no upper casing the numbering is applied before any sorting"; my %ucol = (); $ucol{default} = 0; $parameters{com} = "comment line: character(s) placed at the very beginning of a line in the input file to indicate that it is must be neglected (for instance a commentary)"; my %com = (); $com{default} = "#"; $parameters{ins} = "character(s) placed at the very beginning of a line in the input file to indicate that a parameter line is starting (for instance to put bold characters to the next line)"; my %ins = (); $ins{default} = ":TABLA:"; $parameters{sepa} = "separator, a character or a character string (without blanks) placed between the cell values of the input table"; my %sepa = (); $sepa{default} = ";;"; $parameters{lfile} = "final name of the log file (a valid path can be included)"; my %lfile = (); $lfile{default} = "tabla.log"; $parameters{noval} = "character string to replace a non filled value (last cells) of a row"; my %noval = (); $noval{default} = "-"; $parameters{miwi} = "minimum width in characters of columns/fields (only for table/label output)"; my %miwi = (); $miwi{default} = 1; $parameters{mawi} = "maximum width in characters of columns/fields (only for table/label output)"; my %mawi = (); $mawi{default} = 20; $parameters{lacol} = "(only for label structure) the absolute value gives the number of columns of labels; records are proposed by rows."; my %lacol = (); $lacol{default} = 3; $parameters{alig} = "type of alignment within columns or within labels"; my %alig = (); $alig{default} = "c"; $alig{c} = "centered columns"; $alig{l} = "left aligned columns"; $alig{r} = "right aligned columns"; $parameters{tit} = "title of the table in the first record"; my %tit = (); $tit{default} = "y"; $tit{y} = "title in the 1rst line"; $tit{n} = "no title in input file"; $parameters{seplist} = "delimiter to use between elements for lists this parameter is overloaded in case of latex tables"; my %seplist = (); $seplist{default} = " / "; $parameters{ffla} = "number of labels before a small jump (only for \"t3\" output"; my %ffla = (); $ffla{default} = 5; # # ending parameter definitions # ############################################# ############################################# # # beginning of subroutines # ### displaying the table of help contents sub tableaide { print $bandeau,"\n"; print "\n Table of Contents\n\n"; foreach (sort keys %aide) { print $_,": "; print substr($aide{$_},0,index($aide{$_},"\n")),"\n"; } print "\n just type \"tabla -h all\" to get the complete help..."; print "\n or \"tabla -h \#\" to only get chapter \#"; print "\n or \"tabla -h par\" to get the list of parameters"; print "\n or \"tabla -h par \#\" to get details about parameter \#\n"; } ### decoding possible help among arguments sub aidons { # displaying help my ($i,$quelh,$chapitre,$res); $res = -1; if ($#ARGU < 0) { # no arguments => the table of contents &tableaide; $res = 1; } else { $quelh = -1; for ($i = 0; $i <= $#ARGU; $i++) { if (($ARGU[$i] eq "-h") || ($ARGU[$i] eq "-H")) { $quelh = $i; } } if ($quelh > -1) { $res = 1; $chapitre = $ARGU[$quelh+1]; if (exists($aide{$chapitre})) { print $bandeau,"\n"; print $chapitre,": ",$aide{$chapitre},"\n"; print $bandeau; } elsif ($chapitre eq "all") { print "\n Manual of $sig\n\n"; foreach (sort keys %aide) { print "\n",$bandeau; print $_,":\n "; print $aide{$_},"\n"; } } elsif ($chapitre eq "par") { print $bandeau; $para = $ARGU[$quelh+2]; if (exists($parameters{$para})) { &printpara; } elsif ($para eq "all") { foreach $para (sort keys %parameters) { print "-"x25; &printpara; } } else { print "\n List of all \"inline\" parameters\n\n"; $~ = "parameters"; foreach (sort keys %parameters) { write; } print "\n\n For more details on parameter toto, run \"tabla -h par toto\"\n\n"; } } else { # bad request => the table of contents &tableaide; } } } $res; } ### printing information about parameter $para sub printpara { print "\nabout parameter <<",$para,">>:\n\n"; print "role is: ",$parameters{$para},"\n\n"; my $aaa = "\$defdef = \$".$para."{default};"; eval($aaa); print "default value is: \"",$defdef,"\"\n\n"; $aaa = "%defdef = %".$para.";"; eval($aaa); delete($defdef{default}); @defdef = keys(%defdef); if ($#defdef < 0) { print "no predefined values for this parameter !\n\n"; } else { print "predefined values are: \n\n"; $~ = "parameterdetails"; foreach(sort keys %defdef) { write; } print "\n"; } } ### writing a message in $log before dying sub didi { print LOG "#FATAL#ERROR# ",$_[0],"\n"; die(("<*ERREUR*FATALE*>"x5)."\n".$_[0]."\n $sig is very sorry!"); } ### writing a message in $log and a warning to the monitor sub wawa { print LOG "###warning: ",$_[0],"\n"; print $_[0],"\n"; } ### reading the parameters from a file sub fileparameters { open(ARGU,"".$_[0]) || didi ("(?) can't access to parameter file \"".$_[0],"\""); @argu = (); while() { chop; unless ($_ =~ /^\#/) { while ($_ =~ /^ /) {$_ = substr($_,1);} @argu = (@argu,split(/ +/,$_)); } } close(ARGU); } ### some checking and transforming the inline arguments into parameters sub arguparameters { $nbae = int((scalar(@ARGU)-1) / 2); if (scalar(@ARGU) != 2 * $nbae +1) {didi("$sig(2): ".scalar(@ARGU)." is a bad number of arguments (must be even plus file name)!")} for (my $na = 0; $na < $nbae; $na++) { if (substr($ARGU[2*$na],0,1) ne "-") { didi("$sig(3): missing \"-\" for argument type number ",$na+1,": sorry we were asked to be strict!"); } $ARGU[2*$na] = substr($ARGU[2*$na],1); } } ### some checking and transforming the parameter file arguments into parameters sub argufparameters { $nbaef = int(scalar(@argu) / 2); if (scalar(@argu) != 2 * $nbaef ) {didi("(?): ".scalar(@argu)." is a bad number of arguments for the parameter file (must be even)!")} for (my $na = 0; $na < $nbaef; $na++) { if (substr($argu[2*$na],0,1) ne "-") { didi("(?): missing \"-\" for argument type number ",$na+1,": sorry we were asked to be strict!"); } if ($argu[2*$na] eq "pf") { $argu[2*$na] = $argu{pf}; } else { $argu[2*$na] = substr($argu[2*$na],1); } } } ### normalizing the options sub normaoptions { my @check; # checking every parameter foreach (keys %parameters) { # is checking of necessity ? my $aaa = "\@check = %".$_.";"; eval $aaa; if ($#check > 1) { # check must be done my $aargu = "&checkoption($_,%".$_.");"; eval $aargu; } } } ### checking one options sub checkoption { my ($jbd,%jd) = @_; if (!(exists($jd{$argu{$jbd}}))) { wawa("value of parameter \"".$jbd."\" is wrong [".$argu{$jbd}."], and was forced to default: \"".$jd{default}."\""); $argu{$jbd} = $jd{default}; } } ### answering if the possible row $_[0] is selected according to $argu{serows} sub selecrow { my ($nuco,$nbco,@val,$uuu,$vvv,$proteg); if ($argu{serows} eq 0) { # no selection return 1; } elsif (substr($argu{serows},0,1) =~ /\d/) { # selection according to a column value @val = split(/$argu{sepa}/,$_); $nbco = $#val + 1; $nuco = substr($argu{serows},0,index($argu{serows},"/")); # a series of protection to continue... $proteg = $val[$nuco-1]; $proteg =~ s/@/\\@/; $proteg =~ s/\$/\\\$/; if ($nuco > ($nbco+1)) {didi("(?) bad \"serows\" parameter the column for matching does not exist in input file line number $nbr");} $uuu = "\$vvv = (\"".$proteg."\" =~ ".substr($argu{serows},index($argu{serows},"/")).")"; # (je ne suis pas satisfait de ce qui suit car j'aurais voulu sélectionner en cas de mauvaise syntaxe !) if (eval($uuu)) { return (1);} else { return 0;} } else { @val = split(/\//,substr($argu{serows},1)); $nuco = 0; foreach (@val) { if ($_ == $nbr) { $nuco++;}} return $nuco; } } ### ordering according to the distinct options sub ordre { my ($nbr,$typ,$cha,$quoi,$val) = @_[0..4]; my (@val,@res); for (my $i=0; $i < @$val; $i++) { $val[$i] = $val->[$i]; } if ($typ eq "0") { foreach (1..$nbr) {$res[$_-1] = $_; }} elsif ($typ eq "D") { # leaving out the first and last character chop($cha); $cha = reverse($cha); chop($cha); $cha = reverse($cha); @res = split(/\//,$cha); } else { my $i = 0; foreach (@val) { $i++; $or{$i} = $_; } if ($typ eq "A") {@res = sort sortA keys(%or);} if ($typ eq "a") {@res = sort sorta keys(%or);} if ($typ eq "N") {@res = sort sortN keys(%or);} if ($typ eq "n") {@res = sort sortn keys(%or);} } for (my $i = 0; $i <= $#res; $i++) { if (($res[$i] < 1) || ($res[$i] > $nbr)) { wawa(">".$res[$i]."< is a bad value for ".$quoi." order forced to 1!"); $res[$i] = 1; } } return @res; } ### for &order use sub sortA { $or{$a} cmp $or{$b};} sub sorta { $or{$b} cmp $or{$a};} sub sortN { $or{$a} <=> $or{$b};} sub sortn { $or{$b} <=> $or{$a};} ### determining if one row/column is used for sorting sub socr { #local ($nu = $_[0],$ar = $_[0],$ap=$_[1]);??? my $nu = $_[0]; my $ar = $_[0]; my $ap = $_[1]; my $ty = "D"; if ($nu =~ /^\d+/) { if ($ar ne "0") { $ty = substr($nu,-1,1); if (!($ty =~ /A|a|N|n/)) { &wawa("unknown sorting specification forced to \"A\" in \"-$ap $ar\""); $ty = "A"; } $nu = substr($nu,0,length($nu)-1); if (!($nu =~ /\d+/)) { &didi("(?) bad sorting specification in \"-$ap $ar\""); } } else { $ty = "0"; } } return ($nu,$ty); } ### aligning on left or right or centered sub aligne { # $_[0] is the string to align, i.e. to complete or reduce # $_[1] is the size of the string to attain (10 as default) # $_[2] "l" for left (default), "r" for rigth, "c" for centered # $_[3] "character" for completing on left (" " is the default) # $_[4] "character" for completing on rigth (" " is the default) # $_[5] "s" if implied truncation must be done # $_[6] when truncation is performed this string is added # to indicate it ("$" is the default) # # filling the parameters my ($res,$lon,$typ,$fig,$fir,$cut,$ooo,$nau); if ($#_ >= 0) { $res = $_[0];} else { die("\"aligne\" needs at least one argument\n"); } if ($#_ >= 1) { $lon = $_[1];} else { $lon = 10;} if ($lon < 1) { $lon = 10;} if ($#_ >= 2) { $typ = $_[2];} else { $typ = "l";} if (($typ ne "r") && ($typ ne "c")) {$typ = "l";} if ($#_ >= 3) { $fig = $_[3];} else { $fig = " ";} if (length($fig) > 1) { $fig = substr($fig,0,1); } if ($#_ >= 4) { $fir = $_[4];} else { $fir = " ";} if (length($fir) > 1) { $fir = substr($fir,0,1); } if ($#_ >= 5) { $cut = $_[5];} else { $cut = "n";} if ($#_ >= 6) { $nau = $_[6];} else { $nau = "\$";} if ($cut ne "s") {$cut = "n";} $ooo = 1; if ($typ eq "r") { $ooo = -1;} while (length($res) < $lon) { if ($ooo > 0) {$res = $res.$fir; } else {$res = $fig.$res; } if ($typ eq "c") { $ooo = -1 * $ooo; } } if ($cut eq "s") { $ooo = 1; if ($typ eq "r") { $ooo = -1;} while (length($res) > $lon) { if ($ooo > 0) { $res = substr($res,0,length($res)-1-length($nau)).$nau; } else { $res = $nau.substr($res,1+length($nau)); } if ($typ eq "c") { $ooo = -1 * $ooo; } } } return $res; } # # ending subroutines # ############################################# ############################################# # # beginning formats # format parameters = @>>>>>>>>>>: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<... $_,$parameters{$_} . format parameterdetails = @>>>>>>>>>>: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $_,$defdef{$_} . format arguments = @>>>>>>>>>>>>>> @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< "-".$k,$v . # # ending formats # ############################################# ############################################# # # beginning tags # my %entet = ("h"," $sig ", "l"," %% document created by $sig \\documentclass{article} \\begin{document} ", "t", "\n".("="x40)."\n"."table produced by $sig\n"); my %basde = ("h","\n", "l","\\end{document}\n", "t","\n"."="x40); my %bdate = ("h","

<> titre du bandeau <>", "l","\\date{", "t","("); my %edate = ("h","<> 2222/2/2

\n", "l","}\n", "t",")\n\n"); my %btitr = ("h","

", "l","\\section{","t","< "); my %etitr = ("h","

\n","l","}\n", "t"," >\n\n"); my %bstru = ("h0","\n", "h1","
    \n", "h2","
    \n", "h3","
\n", "l0","\\begin{tabular}\n[c]", "l1","\\begin{itemize}\n", "l2","\\begin{description}\n", "l3","\\begin{tabular}\n[c]", "t0","\n", "t1","\n\n", "t2","\n\n", "tt",""); my %estru = ("h0","
\n", "h1","\n", "h2","\n", "h3","\n", "l0","\\end{tabular}\n", "l1","\\end{itemize}\n", "l2","\\end{description}\n", "l3","\\end{tabular}\n", "t0","\n", "t1","\n\n", "t2","\n\n", "tt",""); my %bbold = ("h","", "l","\\textbf{","t","*"); my %ebold = ("h","","l","}", "t","*"); my %bital = ("h","", "l","\\textit{","t","{"); my %eital = ("h","", "l","}", "t","}"); # # ending tags # ############################################# ############################################# # # beginning code # @ARGU = @ARGV; ### giving some help if asked my $affichage_aide = &aidons; ### if not, performing some transformation if ($affichage_aide < 0) { # preparing the log file open(LOG,">$log") || die ("$sig: can't create to tabla.log"); print LOG "#"x3," log file of tabla\n"; print LOG "#"x3,"\n"; print LOG "#"x3," <<< $sig >>>\n"; print LOG "#"x3,"\n"; print LOG "#"x3," used at ",scalar(localtime()),"\n"; print LOG "#"x3,"\n"; # dealing with parameter arguments &arguparameters; # determining the input file $fentree = $ARGU[$#ARGU]; open(ENTREE,$fentree) || didi("$sig(???): unreachable input file $fentree"); # loading the default parameters foreach (keys %parameters) { my $aaa = "\$argu{\$_} = \$".$_."{default};"; eval $aaa; } # overloading the inline parameters for (my $na = 0; $na < $nbae; $na++) { $argu{$ARGU[2*$na]} = $ARGU[1+2*$na]; } # checking the consistency of inline parameters &normaoptions; # is there a parameter file? if ($argu{pf} ne "0") { # opening the parameter file &fileparameters($argu{pf}); # checking and dealing with these ones &argufparameters; # overloading the file parameters for (my $na = 0; $na < $nbaef; $na++) { $argu{$argu[2*$na]} = $argu[1+2*$na]; } # checking the consistency of the new parameters &normaoptions; } # re-overloading the inline parameters to give them the first priority for (my $na = 0; $na < $nbae; $na++) { $argu{$ARGU[2*$na]} = $ARGU[1+2*$na]; } # checking once more the consistency of parameters &normaoptions; ### printing the arguments in the log file my $oldhandle = select(LOG); $~ = "arguments"; select($oldhandle); print LOG "#\n# Arguments Retained:","\n#","-"x19,"\n#\n"; while (($k,$v) = each %argu) { print LOG "#\n# ",substr($parameters{$k},0,25),"...\n"; write LOG; } ### this part is quite raw: to be thought another time my $tp = $argu{o}; my $sortyp = substr($tp,0,1); ### specific modifications according to the type of output if ($tp eq "tt") { $basde{$sortyp} = ""; $entet{$sortyp} = ""; } if ($tp eq "l0") { $argu{seplist} = " & "; } if ($tp eq "l3") { $argu{seplist} = " \\\\\n "; } ### determining the outfile name if ($argu{nm} eq "0") { if ($fentree =~ /\.txt$/) { $fsortie = substr($fentree,0,length($fentree)-4);} else { $fsortie = $fentree; } if ($sortyp eq "h") {$fsortie = $fsortie.".html";} elsif ($sortyp eq "l") {$fsortie = $fsortie.".tex";} else {$fsortie = $fsortie.".txt";} if ($fentree eq $fsortie) { $fsortie = substr($fentree,0,length($fentree)-4)."bis.txt"; } } else { $fsortie = $argu{nm}; } open(SORTIE,">$fsortie") || didi("(?): [$fsortie] not writable as output file"); ### giving some news print " "x3," $sig is transforming \"$fentree\" file \n"; print " "x7,"- into \"$fsortie\" file\n"; print " "x7,"- with format $tp\n"; print LOG "###\n"; print LOG "### input file: ",$fentree,"\n"; print LOG "### output file: ",$fsortie,"\n"; print LOG "###\n"; ### determining if some rows or columns must be retained for sorting my ($nurow,$tycol) = &socr($argu{socols},"socols"); my ($nucol,$tyrow) = &socr($argu{sorows},"sorows"); ### scrutinizing every line and ### - storing retained data into a vector ### - looking for the number of retained rows ### - looking for the number of retained columns # # initializing my $nbcols = 0; my $nbrows = 0; my $nbr = 0; my @tout = (); my @sortcol = (); my @sortrow = (); my $titre = "no title was provided"; while () { $nbr++; # is this line a data line? if (!((/^$argu{com}/) || (/^$argu{ins}/))) { chop; if (($argu{tit} eq "y") && ($nbr == 1)) { $titre = $_; } else { # is the line selected if (&selecrow($_)) { $nbrows++; # accounting for the column number $nbcl = split(/$argu{sepa}/,$_); if ($nbcl == 0) {didi("(?) : a row of input data is empty !\ MAYBE, it is the LAST line?");} if ($nbcols < $nbcl) { $nbcols = $nbcl;} if ($argu{bla} eq "y") { # removing all spaces around the seperators while ($_ =~ / $argu{sepa}/) { s/ $argu{sepa}/$argu{sepa}/;} while ($_ =~ /$argu{sepa} /) { s/$argu{sepa} /$argu{sepa}/;} # removing all spaces at the beginning and the end while ($_ =~ /^ /) { s/^ //;} while ($_ =~ / $/) { s/ $//;} } my @vale = split(/$argu{sepa}/,$_); if ($nucol > 0) { if ($nucol > $nbcl) { push @sortcol, $argu{noval};} else { push @sortcol, $vale[$nucol-1];} } if ($nurow == $nbrows) { @sortrow = @vale;} push @tout, $_; } } } } print " "x7,"- $nbcols is the column number\n"; print " "x7,"- $nbrows is the row number\n"; if ($nbcols == 0) {&wawa("NO ONE COLUMN was obtained... see if you agree!");} if ($nbrows == 0) {&wawa("NO ONE ROW was obtained... see if you agree!");} if ($nurow > $nbrows) { &didi("(?) you asked sorting columns with a row which does not exist!"); } if ($nucol > $nbcols) { &didi("(?) you asked sorting rows with a column which does not exist!"); } ### completing the missing cells for ($jbd = 0; $jbd <= $#tout; $jbd++) { $nbcl = split(/$argu{sepa}/,$tout[$jbd]); for ($jd = 1; $jd <= $nbcols - $nbcl; $jd++) { $tout[$jbd] = $tout[$jbd].$argu{sepa}.$argu{noval}; } } ### determining the rows and columns to display my @ordrerow = &ordre($nbrows,$tyrow,$nucol,"rows", \@sortcol); my @ordrecol = &ordre($nbcols,$tycol,$nurow,"columns",\@sortrow); ### repeating if asked the first row if ($argu{reprow} > 0) { $hl = int($#ordrerow / $argu{reprow}); my $ll = $ordrerow[0]; for my $hh (1..$hl) { my $lll = $hh*($argu{reprow}+1); splice(@ordrerow,$lll,0,$ll); } } ### dealing with column width for the text output # the following exploration is necessary to know the adjusted width for # each column which is stored into @lar if (($tp eq "t0") || ($tp eq "h0") || ($tp eq "l0") || ($tp eq "t3") || ($tp eq "h3") || ($tp eq "l3")) { $la = 1; } else { $la = 0; } if ($la) { if ($sortyp eq "l") { $lla = "\\\$";} else { $lla = "\$";} if ($argu{miwi} > $argu{mawi}) { &didi("(?) you said that minimum width was more that maximum!"); } for ($jbd = 0; $jbd < $nbcols; $jbd++) {$lar[$jbd]=$argu{miwi};} for ($jbd = 0; $jbd <= $#tout; $jbd++) { $nbcl = split(/$argu{sepa}/,$tout[$jbd]); # ajoût des éventuelles valeurs manquantes for ($jd = 1; $jd <= $nbcols - $nbcl; $jd++) { $tout[$jbd] = $tout[$jbd].$argu{sepa}.$argu{noval}; } my @larg = split(/$argu{sepa}/,$tout[$jbd]); for ($sd = 0; $sd < $nbcols; $sd++) { $larg = length($larg[$sd]); # this to prevent bolding or italicizing but not both of them! if ($sortyp eq "t") { $larg = $larg + 2; } if ($lar[$sd] < $larg) {$lar[$sd] = $larg; } if ($lar[$sd] > $argu{mawi}) {$lar[$sd] = $argu{mawi}; } } } if (($tp eq "t3") || ($tp eq "h3") || ($tp eq "l3")) { # giving the same width for all columns in case of labels foreach (@lar) { if ($lala < $_) { $lala = $_; }} foreach (@lar) { $_ = $lala; } } } ### adding the typographical transformations and applying the width restriction $numlig = 0; foreach $hdd (0..$#tout) { $numlig++; $hd = $tout[$hdd]; my @larg = split(/$argu{sepa}/,$hd); foreach (0..$#larg) { $numcol = $_ + 1; $element = $larg[$_]; # putting it the right width if necessary if (($la) and ($sortyp ne "t")) { $element = &aligne($element,$lar[$_],$argu{alig}," "," ","s",$lla); } # upper casing if (($argu{ucol} == $numcol) ||($argu{urow} == $numlig)) { $element = uc($element); } # bolding if (($argu{bcol} == $numcol) ||($argu{brow} == $numlig)) { $element = $bbold{$sortyp}.$element.$ebold{$sortyp}; } # italicizing if (($argu{icol} == $numcol) ||($argu{irow} == $numlig)) { $element = $bital{$sortyp}.$element.$eital{$sortyp}; } if (($la) and ($sortyp eq "t")) { $element = &aligne($element,$lar[$_],$argu{alig}," "," ","s",$lla); } if ($_ == 0) { $hd = $element; } else { $hd = $hd.$argu{sepa}.$element; } if ($printhelp) { warn($hd); } } $tout[$hdd] = $hd; } ### preparing the numbering if ($argu{number} > 0) { # determing the width of this new field if ($#tout < 9) {$lnu = 1;} elsif ($#tout < 99) {$lnu = 2;} elsif ($#tout < 999) {$lnu = 3;} elsif ($#tout < 9999) {$lnu = 4;} else {$lnu = 5;} } ### recording some values... if ($printhelp) { warn "\$sortyp = ",$sortyp; warn "\$tp = ",$tp; warn "\$argu{lacol} = ",$argu{lacol}; } ### writing the output file if ($tp ne "tt") { ## writing the heading print SORTIE $entet{$sortyp}; ## writing the date print SORTIE $bdate{$sortyp},$dat,$edate{$sortyp}; ## writing the title print SORTIE $btitr{$sortyp},$titre,$etitr{$sortyp}; } else { if ($argu{tit} eq "y") {print SORTIE $titre,"\n";} } ## heading of structure print SORTIE $bstru{$tp}; ##################### ##> text table if ($tp eq "t0") { my %tag = (blign => " ", elign => "\n", bcolo => "", ecolo => " "); $hl = 0; foreach (@ordrerow) { $hl++; print SORTIE $tag{blign}; my @larg = split(/$argu{sepa}/,$tout[$_-1]); ## looping onto columns $yd = 0; foreach (@ordrecol) { $yd++; if ($yd == $argu{number}) { print SORTIE $tag{bcolo}; print SORTIE " ((".&aligne($hl,$lnu,"r","0").")) "; print SORTIE $tag{ecolo}; } print SORTIE $tag{bcolo}; print SORTIE $larg[$_-1]; print SORTIE $tag{ecolo}; } if (($#ordrecol +1) < $argu{number}) { print SORTIE $tag{bcolo}; print SORTIE " ((".&aligne($hl,$lnu,"r","0").")) "; print SORTIE $tag{ecolo}; } print SORTIE $tag{elign}; } } ##################### ##> html table elsif ($tp eq "h0") { my %tag = (blign => "\n", elign => "\n", bcolo => "", ecolo => ""); $hl = 0; foreach (@ordrerow) { $hl++; print SORTIE $tag{blign}; my @larg = split(/$argu{sepa}/,$tout[$_-1]); ## looping onto columns $yd = 0; foreach (@ordrecol) { $yd++; if ($yd == $argu{number}) { print SORTIE $tag{bcolo}; print SORTIE " ((".&aligne($hl,$lnu,"r","0").")) "; print SORTIE $tag{ecolo}; } print SORTIE $tag{bcolo}; print SORTIE $larg[$_-1]; # if ($printhelp) { warn($larg[$_-1]);} print SORTIE $tag{ecolo}; } if (($#ordrecol +1) < $argu{number}) { print SORTIE $tag{bcolo}; print SORTIE " ((".&aligne($hl,$lnu,"r","0").")) "; print SORTIE $tag{ecolo}; } print SORTIE $tag{elign}; } } ##################### ##> latex table elsif ($tp eq "l0") { my %tag = (blign => "", elign => "\\\\\\hline\n", ); $hl = $nbcols; if ($argu{number} > 0) {$hl++;} print SORTIE "{|","$argu{alig}|"x$hl,"}\\hline\n"; $hl = 0; foreach (@ordrerow) { $hl++; print SORTIE $tag{blign}; my @larg = split(/$argu{sepa}/,$tout[$_-1]); ## looping onto columns $nbc = 0; foreach (@ordrecol) { $nbc++; if ($nbc > 1) {print SORTIE $argu{seplist};} if ($nbc == $argu{number}) { print SORTIE " ((".&aligne($hl,$lnu,"r","0").")) "; print SORTIE $argu{seplist}; } print SORTIE $larg[$_-1]; if (($_ eq $ordrecol[$#ordrecol]) and ($tp eq "l3")) { print SORTIE "\\\\\n"; } } if (($#ordrecol + 1) < $argu{number}) { print SORTIE $argu{seplist}; print SORTIE " ((".&aligne($hl,$lnu,"r","0").")) "; } print SORTIE $tag{elign}; } } ##################### ##> text bullet list elsif ($tp eq "t1") { my %tag = ( blign => "\n (*) ", elign => "\n", ); $hl = 0; foreach (@ordrerow) { $hl++; print SORTIE $tag{blign}; my @larg = split(/$argu{sepa}/,$tout[$_-1]); ## looping onto columns $nbc = 0; foreach (@ordrecol) { $nbc++; if ($nbc > 1) {print SORTIE $argu{seplist};} if ($nbc == $argu{number}) { print SORTIE " ((".&aligne($hl,$lnu,"r","0").")) "; print SORTIE $argu{seplist}; } print SORTIE $larg[$_-1]; } if (($#ordrecol + 1) < $argu{number}) { print SORTIE $argu{seplist}; print SORTIE " ((".&aligne($hl,$lnu,"r","0").")) "; } print SORTIE $tag{elign}; } } ##################### ##> html bullet list elsif ($tp eq "h1") { my %tag = ( blign => "
  • \n", elign => "
  • \n", ); $hl = 0; foreach (@ordrerow) { $hl++; print SORTIE $tag{blign}; # latex label structure my @larg = split(/$argu{sepa}/,$tout[$_-1]); ## looping onto columns $nbc = 0; foreach (@ordrecol) { $nbc++; if ($nbc > 1) {print SORTIE $argu{seplist};} if ($nbc == $argu{number}) { print SORTIE " ((".&aligne($hl,$lnu,"r","0").")) "; print SORTIE $argu{seplist}; } print SORTIE $larg[$_-1]; } if (($#ordrecol + 1) < $argu{number}) { print SORTIE $argu{seplist}; print SORTIE " ((".&aligne($hl,$lnu,"r","0").")) "; } print SORTIE $tag{elign}; } } ##################### ##> latex bullet list elsif ($tp eq "l1") { my %tag = ( blign => "\\item ", elign => "\\\\\n", ); $hl = 0; foreach (@ordrerow) { $hl++; print SORTIE $tag{blign}; # latex label structure my @larg = split(/$argu{sepa}/,$tout[$_-1]); ## looping onto columns $nbc = 0; foreach (@ordrecol) { $nbc++; if ($nbc > 1) {print SORTIE $argu{seplist};} if ($nbc == $argu{number}) { print SORTIE " ((".&aligne($hl,$lnu,"r","0").")) "; print SORTIE $argu{seplist}; } print SORTIE $larg[$_-1]; } if (($#ordrecol + 1) < $argu{number}) { print SORTIE $argu{seplist}; print SORTIE " ((".&aligne($hl,$lnu,"r","0").")) "; } print SORTIE $tag{elign}; } } ##################### ##> text definition list elsif ($tp eq "t2") { my %tag = ( blign => "\n ", elign => "\n", bcolo => "", ecolo => " ", blist => "<", elist => ">: ", ); $hl = 0; foreach (@ordrerow) { $hl++; print SORTIE $tag{blign}; my @larg = split(/$argu{sepa}/,$tout[$_-1]); ## looping onto columns $nbc = 0; foreach (@ordrecol) { $nbc++; if ($nbc == 1) { if ($nbc == $argu{number}) { print SORTIE $tag{blist}; print SORTIE " ((".&aligne($hl,$lnu,"r","0").")) "; print SORTIE $tag{elist}; print SORTIE $tag{bcolo}; print SORTIE $larg[$_-1]; } else { print SORTIE $tag{blist}; print SORTIE $larg[$_-1]; print SORTIE $tag{elist}; } } elsif ( $nbc == 2) { if ($nbc == $argu{number}) { print SORTIE $tag{bcolo}; print SORTIE " ((".&aligne($hl,$lnu,"r","0").")) "; print SORTIE $argu{seplist}; print SORTIE $larg[$_-1]; } else { if (1 == $argu{number}) { print SORTIE $argu{seplist};} else {print SORTIE $tag{bcolo};} print SORTIE $larg[$_-1]; } } else { if ($nbc == $argu{number}) { print SORTIE $argu{seplist}; print SORTIE " ((".&aligne($hl,$lnu,"r","0").")) "; print SORTIE $argu{seplist}; print SORTIE $larg[$_-1]; } else { print SORTIE $argu{seplist}; print SORTIE $larg[$_-1]; } } } if (($#ordrecol + 1) < $argu{number}) { print SORTIE $argu{seplist}; print SORTIE " ((".&aligne($hl,$lnu,"r","0").")) "; } print SORTIE $tag{ecolo}; print SORTIE $tag{elign}; } } ##################### ##> html definition list elsif ($tp eq "h2") { my %tag = ( blign => "
    \n", elign => "
    \n", bcolo => "
    ", ecolo => "
    ", blist => "
    ", elist => "
    ", ); $hl = 0; foreach (@ordrerow) { $hl++; print SORTIE $tag{blign}; my @larg = split(/$argu{sepa}/,$tout[$_-1]); ## looping onto columns $nbc = 0; foreach (@ordrecol) { $nbc++; if ($nbc == 1) { if ($nbc == $argu{number}) { print SORTIE $tag{blist}; print SORTIE " ((".&aligne($hl,$lnu,"r","0").")) "; print SORTIE $tag{elist}; print SORTIE $tag{bcolo}; print SORTIE $larg[$_-1]; } else { print SORTIE $tag{blist}; print SORTIE $larg[$_-1]; print SORTIE $tag{elist}; } } elsif ( $nbc == 2) { if ($nbc == $argu{number}) { print SORTIE $tag{bcolo}; print SORTIE " ((".&aligne($hl,$lnu,"r","0").")) "; print SORTIE $argu{seplist}; print SORTIE $larg[$_-1]; } else { if (1 == $argu{number}) { print SORTIE $argu{seplist};} else {print SORTIE $tag{bcolo};} print SORTIE $larg[$_-1]; } } else { if ($nbc == $argu{number}) { print SORTIE $argu{seplist}; print SORTIE " ((".&aligne($hl,$lnu,"r","0").")) "; print SORTIE $argu{seplist}; print SORTIE $larg[$_-1]; } else { print SORTIE $argu{seplist}; print SORTIE $larg[$_-1]; } } } if (($#ordrecol + 1) < $argu{number}) { print SORTIE $argu{seplist}; print SORTIE " ((".&aligne($hl,$lnu,"r","0").")) "; } print SORTIE $tag{ecolo}; print SORTIE $tag{elign}; } } ##################### ##> latex definition list elsif ($tp eq "l2") { my %tag = ( blign => "\\item", elign => "\\\\\n", bcolo => "", ecolo => "", blist => " [", elist => "] ", ); $hl = 0; foreach (@ordrerow) { $hl++; print SORTIE $tag{blign}; my @larg = split(/$argu{sepa}/,$tout[$_-1]); ## looping onto columns $nbc = 0; foreach (@ordrecol) { $nbc++; if ($nbc == 1) { if ($nbc == $argu{number}) { print SORTIE $tag{blist}; print SORTIE " ((".&aligne($hl,$lnu,"r","0").")) "; print SORTIE $tag{elist}; print SORTIE $tag{bcolo}; print SORTIE $larg[$_-1]; } else { print SORTIE $tag{blist}; print SORTIE $larg[$_-1]; print SORTIE $tag{elist}; } } elsif ( $nbc == 2) { if ($nbc == $argu{number}) { print SORTIE $tag{bcolo}; print SORTIE " ((".&aligne($hl,$lnu,"r","0").")) "; print SORTIE $argu{seplist}; print SORTIE $larg[$_-1]; } else { if (1 == $argu{number}) { print SORTIE $argu{seplist};} else {print SORTIE $tag{bcolo};} print SORTIE $larg[$_-1]; } } else { if ($nbc == $argu{number}) { print SORTIE $argu{seplist}; print SORTIE " ((".&aligne($hl,$lnu,"r","0").")) "; print SORTIE $argu{seplist}; print SORTIE $larg[$_-1]; } else { print SORTIE $argu{seplist}; print SORTIE $larg[$_-1]; } } } if (($#ordrecol + 1) < $argu{number}) { print SORTIE $argu{seplist}; print SORTIE " ((".&aligne($hl,$lnu,"r","0").")) "; } print SORTIE $tag{ecolo}; print SORTIE $tag{elign}; } } ##################### ##> text label if ($tp eq "t3") { if ($argu{ffla} < 1) { $argu{ffla} = $ffla{default}; } my $J = $#ordrecol; my $I = $#ordrerow; my $C = $argu{lacol} - 1; my $R = ($I - ($I % ($C+1))) / ($C + 1) ; my $N = ($R+1)*($C+1)*($J+1) - 1; my ($j,$jj,$i,$ii,$c,$r,$n,$val); foreach $n (0..$N) { $c = $n % ($C+1); $r = int($n / (($C+1)*($J+1))); $i = $r * ($C+1) + $c; $ii = $ordrerow[$i]; $j = (int($n/($C+1))) % ($J+1); $jj = $ordrecol[$j]; # computing what must be printed out if ($i <= $I) { my @larg = split(/$argu{sepa}/,$tout[$i]); $val = $larg[$j]; } else { $val = " "x$lala; } # doing the right tagging and printing if (($c == 0) and ($j == 0)) { print SORTIE "+"; for my $jbd (0..$C) { print SORTIE "-"x$lala,"+"; } print SORTIE "\n"; } # printing the cell if ($c == 0) { print SORTIE "|"; } print SORTIE $val,"|"; if ($c == $C) { print SORTIE "\n"; } if ($n == $N) { print SORTIE "+"; for my $jbd (0..$C) { print SORTIE "-"x$lala,"+"; } print SORTIE "\n"; } # introducing some separation if ( ($n != $N) and ($c == $C) and ($j == $J) and ((($r+1) % $argu{ffla})) == 0) { print SORTIE "+"; for my $jbd (0..$C) { print SORTIE "-"x$lala,"+"; } print SORTIE "\n"; print SORTIE "\n"x3; } } } ##################### ##> html label if ($tp eq "h3") { my %tag = ( blign => "\n\n", elign => "
    \n", bcolo => "", ecolo => "", bgrow => "", egrow => "", bgcol => "", egcol => "", ); $hl = 0; foreach (@ordrerow) { $hl++; if (($hl % $argu{lacol}) == 1) { print SORTIE $tag{bgrow}; } else { print SORTIE $tag{bgcol};} print SORTIE $tag{blign}; my @larg = split(/$argu{sepa}/,$tout[$_-1]); ## looping onto columns $yd = 0; foreach (@ordrecol) { $yd++; if ($yd == $argu{number}) { print SORTIE $tag{bcolo}; print SORTIE " ((".&aligne($hl,$lnu,"r","0").")) "; print SORTIE $tag{ecolo}; } print SORTIE $tag{bcolo}; print SORTIE $larg[$_-1]; print SORTIE $tag{ecolo}; } if (($#ordrecol +1) < $argu{number}) { print SORTIE $tag{bcolo}; print SORTIE " ((".&aligne($hl,$lnu,"r","0").")) "; print SORTIE $tag{ecolo}; } print SORTIE $tag{elign}; if (($hl % $argu{lacol}) == 0) { print SORTIE $tag{egrow}; } else { print SORTIE $tag{egcol};} } } ##################### ##> latex label elsif ($tp eq "l3") { my %tag = ( blign => "\n\\begin{tabular}\n[c]", elign => "\n\\end{tabular}\n", bcolo => " & ", ecolo => "", bgrow => "", egrow => "\\\\\\hline\n", bgcol => "", egcol => " & \n", ); # simple list style or latex tabular print SORTIE "{|","$argu{alig}|"x$argu{lacol},"}\\hline\n"; $hl = 0; foreach (@ordrerow) { $hl++; if (($hl % $argu{lacol}) == 1) { print SORTIE $tag{bgrow}; } else { print SORTIE $tag{bgcol};} print SORTIE $tag{blign}; print SORTIE "{$argu{alig}}\n"; my @larg = split(/$argu{sepa}/,$tout[$_-1]); ## looping onto columns $nbc = 0; foreach (@ordrecol) { $nbc++; if ($nbc > 1) {print SORTIE $argu{seplist};} if ($nbc == $argu{number}) { print SORTIE " ((".&aligne($hl,$lnu,"r","0").")) "; print SORTIE $argu{seplist}; } print SORTIE $larg[$_-1]; if ($_ eq $ordrecol[$#ordrecol]) { print SORTIE "\\\\\n";} } if (($#ordrecol + 1) < $argu{number}) { print SORTIE $argu{seplist}; print SORTIE " ((".&aligne($hl,$lnu,"r","0").")) "; } print SORTIE $tag{elign}; if ((($hl % $argu{lacol}) == 0) or ($_ eq $ordrerow[$#ordrerow])){ print SORTIE $tag{egrow}; } else { print SORTIE $tag{egcol};} } } ##################### ##> input table elsif ($tp eq "tt") { my %tag = ( blign => " ", elign => "\n", ); $hl = 0; foreach (@ordrerow) { $hl++; print SORTIE $tag{blign}; my @larg = split(/$argu{sepa}/,$tout[$_-1]); ## looping onto columns $nbc = 0; foreach (@ordrecol) { $nbc++; if ($nbc > 1) {print SORTIE $argu{seplist};} if ($nbc == $argu{number}) { print SORTIE " ((".&aligne($hl,$lnu,"r","0").")) "; print SORTIE $argu{seplist}; } print SORTIE $larg[$_-1]; } if (($#ordrecol + 1) < $argu{number}) { print SORTIE $argu{seplist}; print SORTIE " ((".&aligne($hl,$lnu,"r","0").")) "; } print SORTIE $tag{elign}; } } ## bottom of table print SORTIE $estru{$tp}; ## writing the bottom print SORTIE $basde{$sortyp}; ### closing files close(SORTIE);close(LOG);close(ENTREE); if ($argu{lfile} ne $log) { ### giving another name to the log file move($log,$argu{lfile}) || didi("(?) cannot rename the log file into $argu{lfile}"); } } # # ending code # #############################################