#!/usr/bin/perl -w use HTML::Template; # For the sake of clarity # I have removed some unnecessary variables # Printing them my $cnt; foreach my $mset (@motif_set) { $cnt++; if ( $cnt == 1 ) { my $template = HTML::Template->new( filename => 'fail_template.tmpl' ); #my $template = HTML::Template->new( filename => 'success_template.tmpl' ); $template->param( MOTIF => change_motif_to_iupac($mot) ); $template->param( REDDM => $redstrs); $template->param( SIGSC => $wscr); my @loopdata; foreach my $inst ( @inset ) { my %row_data; # get a fresh hash for the row data $row_data{INST} = $inst; push (@loopdata, \%row_data); } $template->param(LOOP1 => \@loopdata); $template->param( FIG => $wln1 ); print OUTFILE $template->output; } else { my $template2 = HTML::Template->new( filename => 'fail_template.tmpl' ); #my $template2 = HTML::Template->new( filename => 'success_template.tmpl' ); $template2->param( MOTIF => change_motif_to_iupac($mot) ); $template2->param( REDDM => $redstrs2); $template2->param( SIGSC => $wscr2); my @loopdata2; foreach my $oinst ( @oinset ) { my %row_data2; # get a fresh hash for the row data $row_data2{INST} = $oinst; push (@loopdata2, \%row_data2); } $template2->param(LOOP1 => \@loopdata2); $template2->param( FIG => $wln2 ); print OUTFILE $template2->output; } } close ( OUTFILE ); # close output file system("chmod a+x $outfile");