hai monks, i have one sequence as follows,
MAIFNSLVFLPASFTLSYMWNFGSMLGIMLMSQILTGFFLTFYYTAGEAFSSVQYIMFEVNLGWLLRIMH +SNGASMFFLFIYLHIFKGLIYGSYRLIGVWLSGIFIYFLLMGIAFTGYVLIWGQMSYWAAVVITSLMTS +VPYLGKYLVWWGSFSVCENTLKFFYSVHFILPWSLMVLVVFHLFFLHFTGSSSSLYCHGDYDKIHFFPS +FWLKDGFDIFFYFFLILFSLYFSFDLSDPMIFVESDSMAS
output of the above code should be like in this format;
MAIFNSLVFL PASFTLSYMW NFGSMLGIML MSQILTGFFL TFYYTAGEAF SSVQYIMFEV NLGWLLRIMH SNGASMFFLF IYLHIFKGLI YGSYRLIGVW LSGIFIYFLL MGIAFTGYVL IWGQMSYWAA VVITSLMTSV PYLGKYLVWW IWGSFSVCEN TLKFFYSVHF ILPWSLMVLV VFHLFFLHFT G<font color=red>SSS</font +>LYCHG
In the above sequence the search patter is 'SSS' if they their are 4 'S' continousely then it should be colored as SSSS In case if the search patter is found between two gaps of the sequences like as follows the it should be colored as follows MAIFNSVFSS SSALKM i tryed it by as following codes
My code is @y=q{MAIFNSLVFLPASFTLSYMWNFGSMLGIMLMSQILTGFFLTFYYTAGEAFSSVQYIMFEVNLGWL +LRIMHSNGASMFFLFIYLHIFKGLIYGSYRLIGVWLSGIFIYFLLMGIAFTGYVLIWGQMSYWAAVVIT +SLMTSVPYLGKYLVWWGSFSVCENTLKFFYSVHFILPWSLMVLVVFHLFFLHFTGSSSSLYCHGDYDKI +HFFPSFWLKDGFDIFFYFFLILFSLYFSFDLSDPMIFVESDSMAS}; while($j<$n-$m) { if($lastch==$y[$j+$m-1] && $firstch == $y[$j]){ $data="";$pat=""; for($i=$m-1;$i>=0;$i--){ $data=$y[$j+$i].$data; $pat=$x[$i].$pat; } if($data eq $pat){ @start=($j); @end=$j+$m; print "<b><font color=brown face=britanic,helvetica,sans-serif,times, +gill,courier size=4>Match Position : ",$j+1; #print "\n$entry\n$title +\n$acc \n SEQUENCES=>\n@y\n\n"; print " - ", $j +$m,"</b></font>"; print "<font color=blue size=4 face=\"courier\"><b>";$ss=0; for(my $j=0;$j<=$#start;$j++) { for(my $i=$ss;$i<=$#y;$i++) { if($start[$j] == -1) { next; } if($i % 10 == 0) { print " ";} if($i % 50 == 0) {print "<br>";print OUTFILE"\n";} if($start[$j] != $i && $i<$start[$j]) { print "$y[$i]"; print OUTFILE "$y[$i]"; } if($start[$j] == $i) { line: $k=$i; do { print "</b></font><font color=red siz +e=4 face=\"courier\"><b><blink>"; if($k % 10 == 0 && $k != $start[$j]) { print " "; print OUTFILE " "; } if($k % 50 == 0 && $k != $start[$j]) { print "<br>";print OUTFILE "\n"; } print "$y[$k]</b></blink></font><font +color=blue size=4 face=\"courier\"><b>"; print OUTFILE "$y[$k]"; $k++; }until($end[$j] == $k || $end[$j+1] == $k +);$ss=$k; if($k-1 == $start[$j+1]) { $i=($start[$j+1])+1; $j=$j+1;goto line; } elsif($k-1>=$start[$j+1] && $j <$#start) { $i=$k; $j=$j+1;goto line; } else {last;} } } } for(my $i=$k;$i<$#y;$i++) { if($i % 10 == 0) { print " "; print OUTFILE " ";} if($i % 50 == 0 ) {print "<br>";print OUTFILE "\n";} print "</b></font><font color=blue size=4 face=\"c +ourier\"><b>$y[$i]"; print OUTFILE "$y[$i]"; } print "</b></font><br> <hr color=navy>";
can i able to reduce this code so, Please, give me any suggession on it, because it take more time to execute this program as i colored the pattern by using arrays, if their is any way to reduce the code so, i am eager to know the answer, form you monk, please can any body give me suggession so for it. by sanku.

In reply to splitting and coloring by sanku

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.