I have program in Perl and it invok a database en postgrest, and I use
commands as it: my $pdbh = Pg::connectdb($p_dbms) || die "no se puede conectar."; $x = $codigo;
$res= Pg::doQuery($pdbh, "SELECT * FROM gente WHERE codigo = $x",\@ar)
then when I run the program it present errores as Undefined subroutine&Pg::connectdb called at bd_pons1.pl line 135.
main::Accese_Bdcalled at bd_pons1.pl line 23
I want know if can you help me below find the script and can you test and
tell me where is the problem please.
thanks
#!/usr/bin/perl
# --------------------------------------------------------------bd_pons.pl
# Este programa para atender la solicitud de consulta o
# actualizacin.
#
# --------------------------------------------------------------------
use CGI qw /:standard/;
#use DBI;
#
#use Pg;
my $p_dbms = "dbname=philip user=philip";
my $p_user = "user=philip";
my $p_pw = "password=";
#my $q = new CGI /qw:standard/;
#print $q->header;
$entrada=&Entrada; &Parametros ($entrada); &Cabecera_HTML; &Accese_Bd; if (&Va_Actualizar) {
&Proceso_Act; exit 0; } elsif (&Va_Home_Page) { &Proceso_Home_Page;
exit 0; } else { &Proceso_Consulta; exit 0; }
sub Proceso_Consulta { print "<head>\n"; print "<title>Que Toque</title>\n"; print "</head>\n";
print"<body bgcolor=\"\#FFFFFF\">\n"; print "<h1 align=\"center\">IPI\.</h1>\n"; print "<hr>\n";
print"<p> </p>\n";
print "<h3 align=\"center\">Cdigo de usuario $x</h3>\n";
print "<h3 align=\"center\">Nombre: $nom Depto: $dpto</h3>\n"; print "<h3 align=\"center\">Telefono: $tel
</h3>\n"; print "<h3 align=\"center\">Correo: $k_corr al $f_corr </h3>\n"; print "<h3
align=\"center\">Directorio: $k_home al $f_home
</h3>\n"; print "<h3 align=\"center\">Tiene home page: $h_p; Fecha
vencimiento: $ print "<h3 align=\"center\">Informacin adicional: $info_gen
</h3>\n";
print "<h3 align=\"center\">Muchas Gracias</h3>\n"; print "</body>\n"; print "</html>\n";
}
sub Entrada{ local ($entrada); if ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN, $entrada,
$ENV{'CONTENT_LENGTH'}); }else{ $entrada = $ARGV[0]; } return $entrada;
}
sub Parametros { local ($linea) = @_; $linea =~ s/\?/ /g; $linea =~ s/\+/ /g; $linea =~
s/\&/=/g; $linea =~ s/%(..)/pack("C",hex($1))/ge; @regis = split(/=/, $linea); $codigo = $regis[1];
$define = $regis[3];
# print "<h3 align=\"center\">$clave es $valor</h3>\n";
}
sub Cabecera_HTML{ print "Content-type: text/html\n\n";
}
sub Va_Actualizar { if ($actualiza) { return 1;
# print "<h3 align=\"center\">VINO POR ACTUALIZA</h3>\n"; } return 0;
}
sub Proceso_Act { print "<head>\n"; print "<title>Actualizacin de Usuarios</title>\n"; print
"</head>\n";
print "<body>\n";
print "<h2>Centro de Informtica: \n"; print "Administracin de Usuarios.</h2>\n";
print "<FORM ACTION=\"bd_act_man.pl\" METHOD=POST>\n"; print " <p> Actualizacin del Cdigo de Usuario \n";
print "<INPUT NAME=\"entry\" value=$entry size=\"8\">\n"; print "<BR><BR>\n"; print "Telfono: <INPUT
NAME=\"telef\"value= $tel size=\"8\">\n"; print "_____Fecha Ingreso: <INPUT NAME=\"f_ent\" size=\"10\">\n";
print"_____Fecha Vencimiento: <INPUT NAME=\"f_venc\"\n"; print " value=$f_venc size=\"10\"><BR><BR>\n";
$x_gen= '"' . $info_gen . '"'; print "Info Adicional: <INPUT NAME=\"inf_ad\" value=$x_gen
size=\"20\"> print "<BR>\n"; print "<INPUT TYPE=submit
NAME=\"actualice\" VALUE=\"actualice\">\n"; print "</form>\n"; print "</body>\n"; print "</html>\n";
}
sub Va_Home_Page { if ($home_page) { return 1; } return 0;
}
sub Proceso_Home_Page { print "<h3 align=\"center\">VINO POR HOME_PAGE</h3>\n";
}
sub Accese_Bd { my $pdbh = Pg::connectdb($p_dbms) || die "no se puede conectar."; $x = $codigo;
$res= Pg::doQuery($pdbh, "SELECT * FROM gente WHERE codigo = $x",\@ar)
$ced = $ary[0][1]; $nom = $ary[0][2]; $dpto = $ary[0][3]; $tel = $ary[0][4];
$c_corr = int ($ary[0][5] / 1024); $k_corr = $c_corr . "k"; $f_corr = $ary[0][6]; $c_home =
$ary[0][7]; $k_home = $c_home . "k"; $f_home = $ary[0][8]; $h_p = $ary[0][9]; $f_venc =
$ary[0][10]; $info_gen = $ary[0][11];
if (($h_p eq "t") || ($h_p eq "T")) { $h_p = "S"; } else { $h_p = "No";
}
}