Hi. Nowdays I programing a code for iCall application on internet. I wrote code which show table with days of month. You can click on day and show you table with hours and minutes. And here is my little problem. Code is fully functional but is big and gauche, I think. Do you have some idea how can I make my code smaller and profesional??? Here is link where you can see result and try it.

[- use Date::Calc qw(:all); %mesiac=(1=>'January', 2=>'February', 3=>'March', 4=>'April', 5=>'May' +, 6=>'June', 7=>'July', 8=>'August', 9=>'September', 10=>'October', 1 +1=>'November', 12=>'December'); %den=(1=>'Monday', 2=>'Tuesday', 3=>'Wednesday', 4=>'Thursday', 5=>'Fr +iday', 6=>'Saturday', 7=>'Sunday'); $day = $fdat{day}; $month = $fdat{month}; $year = $fdat{year}; $dom = Days_in_Month($year,$month); -]

This part of code testing which days will be next or previous and create anchors for these days. This part is big and I think may be write better, but I dont know how. Please write some idea how can I do it better.

[$ if ($day == $dom) $] [- if ($month == 12) { $mmonth = 1; $myear = $year+1; } else { $mmonth = $month+1; $myear = $year; } $day1 = $day-2; $day2 = $day-1; $day3 = 1; $day4 = 2; $dow1=Day_of_Week($year,$month,$day1); $dow2=Day_of_Week($year,$month,$day2); $dow3=Day_of_Week($myear,$mmonth,$day3); $dow4=Day_of_Week($myear,$mmonth,$day4); $dow=Day_of_Week($year,$month,$day); -] <center> <a href="?mod=day&month=[+ $month +]&year=[+ $year +]&day=[+ $day1 +]" +>[+ $den{$dow1} +]</a>&nbsp;&nbsp;&nbsp; <a href="?mod=day&month=[+ $month +]&year=[+ $year +]&day=[+ $day2 +]" +>[+ $den{$dow2} +]</a>&nbsp;&nbsp;&nbsp; [+ $den{$dow} +]&nbsp;&nbsp;&nbsp; <a href="?mod=day&month=[+ $mmonth +]&year=[+ $myear +]&day=[+ $day3 + +]">[+ $den{$dow3} +]</a>&nbsp;&nbsp;&nbsp; <a href="?mod=day&month=[+ $mmonth +]&year=[+ $myear +]&day=[+ $day4 + +]">[+ $den{$dow4} +]</a> </center></br> [$ elsif ($day == $dom-1) $] [- if ($month == 12) { $mmonth = 1; $myear = $year+1; } else { $mmonth = $month+1; $myear = $year; } $day1 = $day-2; $day2 = $day-1; $day3 = $day+1; $day4 = 1; $dow1=Day_of_Week($year,$month,$day1); $dow2=Day_of_Week($year,$month,$day2); $dow3=Day_of_Week($year,$month,$day3); $dow4=Day_of_Week($myear,$mmonth,$day4); $dow=Day_of_Week($year,$month,$day); -] <center> <a href="?mod=day&month=[+ $month +]&year=[+ $year +]&day=[+ $day1 +]" +>[+ $den{$dow1} +]</a>&nbsp;&nbsp;&nbsp; <a href="?mod=day&month=[+ $month +]&year=[+ $year +]&day=[+ $day2 +]" +>[+ $den{$dow2} +]</a>&nbsp;&nbsp;&nbsp; [+ $den{$dow} +]&nbsp;&nbsp;&nbsp; <a href="?mod=day&month=[+ $month +]&year=[+ $year +]&day=[+ $day3 +]" +>[+ $den{$dow3} +]</a>&nbsp;&nbsp;&nbsp; <a href="?mod=day&month=[+ $mmonth +]&year=[+ $myear +]&day=[+ $day4 + +]">[+ $den{$dow4} +]</a> </center></br> [$ elsif ($day == 2) $] [- if ($month == 1){ $mmonth = 12; $myear = $year-1; } else { $mmonth = $month - 1; $myear = $year; } $mdom = Days_in_Month($myear,$mmonth); $day1 = $mdom; $day2 = 1; $day3 = 3; $day4 = 4; $dow1=Day_of_Week($myear,$mmonth,$day1); $dow2=Day_of_Week($year,$month,$day2); $dow3=Day_of_Week($year,$month,$day3); $dow4=Day_of_Week($year,$month,$day4); $dow=Day_of_Week($year,$month,$day); -] <center> <a href="?mod=day&month=[+ $mmonth +]&year=[+ $myear +]&day=[+ $day1 + +]">[+ $den{$dow1} +]</a>&nbsp;&nbsp;&nbsp; <a href="?mod=day&month=[+ $month +]&year=[+ $year +]&day=[+ $day2 +]" +>[+ $den{$dow2} +]</a>&nbsp;&nbsp;&nbsp; [+ $den{$dow} +]&nbsp;&nbsp;&nbsp; <a href="?mod=day&month=[+ $month +]&year=[+ $year +]&day=[+ $day3 +]" +>[+ $den{$dow3} +]</a>&nbsp;&nbsp;&nbsp; <a href="?mod=day&month=[+ $month +]&year=[+ $year +]&day=[+ $day4 +]" +>[+ $den{$dow4} +]</a> </center></br> [$ elsif ($day == 1) $] [- if ($month == 1) { $mmonth = 12; $myear = $year-1; } else { $mmonth = $month - 1; $myear = $year; } $dom = Days_in_Month($myear,$mmonth); $day1 = $dom-1; $day2 = $dom; $day3 = 2; $day4 = 3; $dow1=Day_of_Week($myear,$mmonth,$day1); $dow2=Day_of_Week($myear,$mmonth,$day2); $dow3=Day_of_Week($year,$month,$day3); $dow4=Day_of_Week($year,$month,$day4); $dow=Day_of_Week($year,$month,$day); -] <center> <a href="?mod=day&month=[+ $mmonth +]&year=[+ $myear +]&day=[+ $day1 + +]">[+ $den{$dow1} +]</a>&nbsp;&nbsp;&nbsp; <a href="?mod=day&month=[+ $mmonth +]&year=[+ $myear +]&day=[+ $day2 + +]">[+ $den{$dow2} +]</a>&nbsp;&nbsp;&nbsp; [+ $den{$dow} +]&nbsp;&nbsp;&nbsp; <a href="?mod=day&month=[+ $month +]&year=[+ $year +]&day=[+ $day3 +]" +>[+ $den{$dow3} +]</a>&nbsp;&nbsp;&nbsp; <a href="?mod=day&month=[+ $month +]&year=[+ $year +]&day=[+ $day4 +]" +>[+ $den{$dow4} +]</a> </center></br> [$ else $] [- $day1 = $day-2; $day2 = $day-1; $day3 = $day+1; $day4 = $day+2; $dow1=Day_of_Week($year,$month,$day1); $dow2=Day_of_Week($year,$month,$day2); $dow3=Day_of_Week($year,$month,$day3); $dow4=Day_of_Week($year,$month,$day4); $dow=Day_of_Week($year,$month,$day); -] <center> <a href="?mod=day&month=[+ $month +]&year=[+ $year +]&day=[+ $day1 +]" +>[+ $den{$dow1} +]</a>&nbsp;&nbsp;&nbsp; <a href="?mod=day&month=[+ $month +]&year=[+ $year +]&day=[+ $day2 +]" +>[+ $den{$dow2} +]</a>&nbsp;&nbsp;&nbsp; [+ $den{$dow} +]&nbsp;&nbsp;&nbsp; <a href="?mod=day&month=[+ $month +]&year=[+ $year +]&day=[+ $day3 +]" +>[+ $den{$dow3} +]</a>&nbsp;&nbsp;&nbsp; <a href="?mod=day&month=[+ $month +]&year=[+ $year +]&day=[+ $day4 +]" +>[+ $den{$dow4} +]</a> </center></br> [$ endif $]
This little code generate table with hours and minutes.
<center>[+ $day +].&nbsp;[+ $mesiac{$month} +]&nbsp;[+ $year +]&nbsp;& +nbsp;&nbsp;</center> <center> <table width="60%" border="1"> [- $hour = 6 -] [$ while $hour<=20 $] [- $min = 00 -] [$ while $min <= 30 $] <tr> [$ if ($min == 0) $] <td width="20%">[+ $hour +]:[+ $min +][+ $min +]</td> [$ else $] <td width="20%">[+ $hour +]:[+ $min +]</td> [$ endif $] <td> &nbsp; </td> </tr> [- $min += 30 -] [$ endwhile $] [- $hour += 1 -] [$ endwhile $] </table> <a href="?mod=calendar&amonth=[+ $month +]&ayear=[+ $year +]">Back on +the week</a></br> </center>

Thanks for all ideas.

Programing in Embperl and all questions are related to Embperl.
Excuse my bad English !!!

Edited by Chady -- moved node out of `pmsig' div


In reply to Make code smaller and better by Wampa

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.