hai monks,
#!/usr/bin/perl print "content-type:text/html\n\n"; use CGI; $cgi=new CGI; $search=$cgi->param('search'); $search='SSSS';# it may be any patterns like AAAA,ADLSD etc., $search='SIVA'; $count=0; print "<html><title>Search String in SWISS-PROT</title><head><center>< +h3><b><font face=courier size=5 color=green> Matching String Position + in SWISS-PROT </font></h3></center><hr>"; print "<pre><p align=left><font face=courier size=4 color=green>\t\t\t + Searched String is </font><b><font face=courier color=red +size=4 style=\"BACKGROUND-COLOR: white\">$search</font></b></p></pre> +"; print "<style type=\"text/css\">"; print "a { text-decoration:none; }"; print "</style></head>"; print "<body bgcolor=aliceblue alink=black>"; $patterlength=length($search); print "<pre>"; @arrat2 = (); #@array2 = $_; @array2=("MASVKSSSSSSSSSFISLLLLSIVAIAAAALLVIVLQAAAASQVIECQ +PQQSCTASLTGSIVALNVCAPFLVPGSIVASPTASADLSDTECCNAVADLSDQSINHDCMCNTMRIAAQ +IPAQCNLPPLSCSANSSS"); $result=index($array2[$i],$search); while ($result != -1) { $offset = $result + 1; push(@start1,$offset); push(@start,($offset-1)); $result = index($array2[$i1], $search, $offset); $result2= $offset +(length($search)); push(@end1,$result2); push(@end,$result2-1); print "<b><font face=courier size=4 color=green>Matching Position </fo +nt><font color=red>[",$offset," - ",$result2,"]</font></b>\n"; } if (defined $array2[0]) { @arr = split('',$array2[0]); } print "<font size=4 face=courier>";$ss=0; for(local $j=0;$j<=$#start;$j++) { for(local $i=$ss;$i<=$#arr;$i++) { if($start[$j] == -1) {next;} if($i % 10 == 0) { print " ";} if($i % 60 == 0) {print "<br>";} if($start[$j] != $i && $i<$start[$j]) { print "$arr[$i]"; } if($start[$j] == $i) { line: $k=$i; do { if($k % 10 == 0 && $k != $start[$j]) { print " "; } if($k % 60 == 0 && $k != $start[$j]) { print "<br>"; } print "<FONT style=\"BACKGROUND-COLOR: blue \" color=white><b><blink> +$arr[$k]</blink></b></font>";$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(local $i=$k;$i<$#arr;$i++) { if($i % 10 == 0) { print " ";} if($i % 60 == 0 ) {print "<br>";} print "$arr[$i]"; }@arr=(); print "</font><hr>";
By download and executing this perl program i think you may get an idea about what i am saying. Actually it is a cgi program. So, you also execute it in apache web browser.So, that you can able to understand what iam saying. i wants to minimize the above code by using regular expressions, where us right now i had solved it by using array. any suggessions please!!!!! thanks in advance, by tony1

In reply to coloring patterns of an array by Tony1

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.