#!/usr/bin/perl use strict; my $dir = @ARGV[0]; my $htmldir = @ARGV[1]; if ( ! -d $htmldir ) { `mkdir $htmldir`; } if ( ! -d "$htmldir/html" ) { `mkdir $htmldir/html`; } if ( ! -d "$htmldir/html/picts" ) { `mkdir $htmldir/html/picts`; } my $html = "$htmldir/html"; my @meshes = glob($dir.'/ProgramOutput.*'); my @corenames; foreach (@meshes) { #get name (my $corename) = ( $_ =~ m/ProgramOutput\.(.*)\.txt/ ); push(@corenames,$corename); # generate histogram svg my $svg_out = "picts/$corename.svg"; `create_histogram.pl $dir/$corename-histo.txt > $html/$svg_out`; } my $out_filename = "$html/results.html"; open(my $out, ">", $out_filename) || die("Impossible d'ouvrir $out_filename: $!"); print $out " \n"; foreach (@corenames) { if ( (my $mesh_file) = ( $_ =~ m/(^[^_]*)_0$/ ) ) { print $out "

$mesh_file

\n"; } if ( (my $mesh_file) = ( $_ =~ m/(^[^_]*_[0-9]+)$/ ) ) { print $out "

$mesh_file

\n"; } print $out "
\n"; my $svg_file = svg_name($_); if ( -f "$html/$svg_file" ) { print $out "\n"; } else { print $out "\n"; } print $out "
\n"; print $out "

$_: "; my $btitle = 1; my $out_file = out_name($_); open(my $fic, $out_file) || die("Impossible d'ouvrir $out_file: $!"); while( <$fic> ) { chomp $_; $_ =~ s/^(--.*)/$1<\/span>/; $_ =~ s/^(ERROR.*| ! .*)/$1<\/span>/; $_ =~ s/(\[.*\])$/$1<\/span>/; $_ =~ s/\(([0-9]{3}[0-9]*|[0-9\.]{4}).*s\)/\($1s\)<\/span>/; if ( $btitle==1 ) { $_ = $_."

"; $btitle=0;} else { $_ = $_."
"; } print $out "$_"; } print $out "\n
\n"; } print $out ""; sub svg_name() { my $arg = shift; return "picts/$arg.svg"; } sub out_name() { my $arg = shift; return "$dir/ProgramOutput.$arg.txt"; }