#!/usr/bin/perl -wT use strict; use CGI qw/:standard/; use DBI; print header, start_html('Database Interface'), h1('first test of a query! Just in a few DNA-Sequences:'),hr, start_form, textarea( -name =>'input', -default=>'Enter your sequence here...', -rows=>'10', -columns=>'50'),br, 'Choose the table: ', popup_menu( -name =>'table', -values =>[qw/dnaseq protseq/], -labels =>{'dnaseq'=>'DNA-Sequences','protseq'=>'Protein-Sequences'}),p, submit('subm','submit'),p, end_form, hr; my $popup_menu_value = param('table'); my $input; my @result; if( $popup_menu_value eq "dnaseq"){ $input = uc param('input'); #uc wandelt Klein- in Großbuchstaben um } else{ $input = lc param('input'); #lc wandelt Groß- in Kleinbuchstaben um } import_names('items'); if ($items::subm) { my $table = param('table'); my $query = "select * from $table where seq like '%$input%';"; my $dbname = 'perl'; my $seqs = DBI->connect("dbi:Pg:dbname=$dbname",'marc','') or die "Kann keine Verbindung herstellen: $DBI::errstr"; my $sql = $seqs->prepare($query) or die "Kann die Abfrage nicht vorbereiten: $DBI::errstr"; $sql->execute(); print "Result is:",p; print(" "); my $counter = 0; while(@result = $sql->fetchrow_array() ){ $counter++; print(" ", ""); } print("
# Sequence
",checkbox($counter)," $result[ 1 ]
"); print start_form, submit('show','show'),p, end_form, hr; } elsif ($items::show) { print ( ... ); }