#!/usr/bin/perl use strict; use warnings; use CGI; my $WIDTH = 40; my %hash = ( 'name1' => "ATATTATCCCCCTATATATGGAGGGAGAGGGGGGGGGGGGGGGGGGGGGGGGGGGAGAGAGGAGATTTTTTTTTTTTTTTT", 'name2' => "ATATATTATATATATTATATTCGCGCGCGCGGCGCGCGCGGCGCGCGCGTTTTTTTTTTTTTTAGGAGAGAGAGGGAGGAGGAGAGGGGAGT", ); my @select=(); my %pattern = ( 'AGGAG' => 'sd', 'TTTTTTT' => 'terminator' ); my $re = join '|',keys %pattern; # add markup foreach my $key (sort keys %hash) { if ($hash{$key} =~ s!($re)!$1!g){ push @select,$key; } } # create table my $table = q!!; # selected keys foreach my $key (@select) { my $seq = $hash{$key}; # count ACTG character to determine # position to insert line breaks my $count = 0; my @br; for my $p (0..length($seq)-1){ ++$count if substr($seq,$p,1) =~ /[ACTG]/; if ($count > $WIDTH){ push @br,$p; $count = 1; }; } # insert line breaks working backwards for my $p (reverse @br){ substr($seq,$p,0,'
'); } # create row my $radio = qq!!; $table .= qq!!; } $table .= q!
Key   Sequence
$key $radio $seq
!; # html page my $q = CGI->new; my $style = < SD sequence or terminator structure!; print $q->header, $q->start_html(-style=>{'code'=>$style}), $q->h1( $note ), $table, $q->end_html;