Hi Experts

Could you pls look into my code and provide feedbacks to improve my coding level, since i am new to this platform

use 5.012; use String::Diff; use strict; use warnings; my $aff_print; my $aff_print1; my $outpath; my $data; my $source; my $mismatch_aff; my $nomismatch_aff; my $outpath1; my $prooftxt; my $proftxt; my $jnl; my $artno; my $aidno; my $xmlpath; my $xml_miss; my $xmltxt; my $xmtxt; my $filename; my $diff; ###### OUT PATH DETAILS ######$jnl=$ARGV[0]; $artno=$ARGV[1]; $outpath=$ARGV[2]; $proftxt=$ARGV[3]; $outpath=~s#T:/PGN/#G:/FROM_3B2/#gi; $outpath=~s#(.+\/.+\)\/)(.+)#$1#gi; $outpath1= $outpath; mkdir "$outpath1"; $outpath= $outpath1; $outpath .= 'affprint.html'; if ($proftxt=~m#<!--aff_print: #gi) { $proftxt=~s#(<!--aff_print: +)(.+)(-->)#$2#g; $aff_print=$2; }else {if (!-e $outpath){$data="<html><head><title>ISSUE REPORT<\/titl +e><\/head><body bgcolor\=\"\#CCFFCC\"><h1 align\=\"center\">MISMATCH +REPORT</h1><table width\=\"1200px\" border\=\"10\" align\=\"center\"f +rame\=\"border\" rules\=\"all\"><thead><tr bgcolor\=\"\#FFCCFF\"><th> +ARTICLE ID<\/th><th>FILE MISSING IN PATH<\/th><th>S100 OUTPUT<\/th><t +h>F300 OUTPUT<\/th><th>DIFFERENCES<\/th><\/tr><\/thead><tbody><\/tbod +y><\/table><\/body><\/html>"; $xml_miss="<tr><td>$jnl$artno</td><td>NO AFF_PRINT IN 3D</td><td\/><td +\/><td\/></tr>"; $data=~s#(<\/tbody><\/table>)#$xml_miss$1#g; &print_outpath(); }else{&read_outpath(); $xml_miss="<tr><td>$jnl$artno</td><td>NO AFF_PRINT IN 3D</td><td\/><td +\/><td\/></tr>"; $data=~s#(<\/tbody><\/table>)#$xml_miss$1#g; &print_outpath(); }}if ($aff_print){$filename=$jnl . $artno; $aidno = sprintf("%08d", $artno); $xmlpath="\\\\tnqfs01\\COPYEDITORS\\TO_3B2\\ELSEVIER\\$jnl\\$aidno\\$f +ilename.xml"; if (!-e $xmlpath){if (!-e $outpath){$data="<html><head><title>ISSUE RE +PORT<\/title><\/head><body bgcolor\=\"\#CCFFCC\"><h1 align\=\"center\ +">MISMATCH REPORT</h1><table width\=\"1200px\" border\=\"10\" align\= +\"center\"frame\=\"border\" rules\=\"all\"><thead><tr bgcolor\=\"\#FF +CCFF\"><th>ARTICLE ID<\/th><th>FILE MISSING IN PATH<\/th><th>S100 OUT +PUT<\/th><th>F300 OUTPUT<\/th><th>DIFFERENCES<\/th><\/tr><\/thead><tb +ody><\/tbody><\/table><\/body><\/html>"; $xml_miss="<tr><td>$jnl$artno</td><td>XML FILE MISSING</td><td\/><td\/ +><td\/></tr>"; $data=~s#(<\/tbody><\/table>)#$xml_miss$1#g; &print_outpath(); }else{&read_outpath(); $xml_miss="<tr><td>$jnl$artno</td><td>XML FILES MISSING</td><td\/><td\ +/><td\/></tr>"; $data=~s#(<\/tbody><\/table>)#$xml_miss$1#g; &print_outpath(); }}else{open (IN,"$xmlpath"); $xmlpath=join("\n", <IN>); close IN; $xmltxt=$xmlpath; $xmtxt=quotemeta($xmltxt); if ($xmtxt=~m#<\\!\\-\\-aff_print\\:\\ #gi) { $xmltxt=~s#<!--aff_p +rint: (.*?)-->#$1#s; $aff_print1=$1; }else {}}if ($aff_print1){if ($aff_print eq $aff_print1){if(!-e "$outp +ath") { $data="<html><head><title>ISSUE REPORT<\/title><\ +/head><body bgcolor\=\"\#CCFFCC\"><h1 align\=\"center\">MISMATCH REPO +RT</h1><table width\=\"1200px\" border\=\"10\" align\=\"center\"frame +\=\"border\" rules\=\"all\"><thead><tr bgcolor\=\"\#FFCCFF\"><th>ARTI +CLE ID<\/th><th>FILE MISSING IN PATH<\/th><th>S100 OUTPUT<\/th><th>F3 +00 OUTPUT<\/th><th>DIFFERENCES<\/th><\/tr><\/thead><tbody><\/tbody><\ +/table><\/body><\/html>"; $nomismatch_aff="<tr><td>$jnl$artno</td><td\/><td\/><td\/><td>NO MISMA +TCH FOUND</td></tr>"; $data=~s#(<\/tbody><\/table>)#$nomismatch_aff$1#g; &print_outpath(); } else { $nomismatch_aff="<tr><td>$jnl$artno</td><td\/><td\ +/><td\/><td>NO MISMATCH FOUND</td></tr>"; &read_outpath(); $data=~s#(<\/tbody><\/table>)#$nomismatch_aff$1#g; &print_outpath(); }}else {if(!-e "$outpath") { $data="<html><head><title>ISS +UE REPORT<\/title><\/head><body bgcolor\=\"\#CCFFCC\"><h1 align\=\"ce +nter\">MISMATCH REPORT</h1><table width\=\"1200px\" border\=\"10\" al +ign\=\"center\"frame\=\"border\" rules\=\"all\"><thead><tr bgcolor\=\ +"\#FFCCFF\"><th>ARTICLE ID<\/th><th>FILE MISSING IN PATH<\/th><th>S10 +0 OUTPUT<\/th><th>F300 OUTPUT<\/th><th>DIFFERENCES<\/th><\/tr><\/thea +d><tbody><\/tbody><\/table><\/body><\/html>"; $mismatch_aff="<tr><td>$jnl$artno</td><td\/><td>$aff_print1<\/td><td>$ +aff_print<\/td><td><\/td><\/tr>"; my $diff = String::Diff::diff_merge("$aff_print1", "$aff_print", + remove_open => '<FONT style="BACKGROUND-COLOR: RED">', remov +e_close => '</FONT>', append_open => '<FONT style="BACKGROUND- +COLOR: FFFF33">', append_close => '</FONT>', ); $mismatch_aff=~s#(<td><\/td>)#<td>$diff<\/td>#g; $data=~s#(<\/tbody><\/table>)#$mismatch_aff$1#g; &print_outpath(); } else { $mismatch_aff="<tr><td>$jnl$artno</td><td\/><td>$a +ff_print1<\/td><td>$aff_print<\/td><td><\/td><\/tr>"; my $diff = String::Diff::diff_merge("$aff_print1", "$aff_print", + remove_open => '<FONT style="BACKGROUND-COLOR: RED">', remov +e_close => '</FONT>', append_open => '<FONT style="BACKGROUND- +COLOR: FFFF33">', append_close => '</FONT>', ); $mismatch_aff=~s#(<td><\/td>)#<td>$diff<\/td>#g; &read_outpath(); $data=~s#(<\/tbody><\/table>)#$mismatch_aff$1#g; &print_outpath(); }}}else {}}else {}sub read_outpath{open FILE, "<$outpath"; read FILE, $data, 100000000; close FILE; }sub print_outpath{open FILE, ">$outpath"; print FILE $data; close FILE; }exit;

Thanks

Basheer


In reply to code for review by basheer

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.