#!/usr/bin/perl use DBI; use CGI qw(:standard *table *Tr); my $dbh = DBI->connect("dbi:Pg:dbname=template1"); my $sth = $dbh->prepare('select id,nombre,apellidos from prueba2 where id >= ? and id <= ?'); $sth->bind_param(1,3); $sth->bind_param(2,5); $sth->execute; print h2('Entre 3 y 5'), start_table, Tr( th( ['Id','Nombre','Apellidos'] ) ), "\n"; while ( @row = $sth->fetchrow_array ) { print Tr(td(\@row)), "\n"; } print end_table; $sth->execute(1,4); print h2('Entre 1 y 4'), start_table, Tr( th( ['Id','Nombre','Apellidos'] ) ), "\n"; while ( @row = $sth->fetchrow_array ) { print Tr(td(\@row)), "\n"; } print end_table; my $rc = $dbh->disconnect();