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#!/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>";
In reply to coloring patterns of an array by Tony1
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |