Coloreado en 0.000 segundos, usando GeSHi 1.0.8.4
1. Primero creé ConectarBD.pm
Using perl Syntax Highlighting
- #!/usr/bin/perl
- package ConectarDB;
- use strict;
- use DBI;
- # VARIABLES A UTILIZAR
- my $db_user = "postgres";
- my $db_pass = "postgres";
- my $host_name = "localhost";
- my $db_name = "sicre";
- # DEFINICION DE LA CONEXION
- my $q_string = "dbi:Pg:host=$host_name;database=$db_name";
- sub connect{
- return (DBI->connect ($q_string, $db_user, $db_pass,
- {PrintError => 0, RaiseError => 1}));
- }
- 1;
Coloreado en 0.003 segundos, usando GeSHi 1.0.8.4
Después desarrollé
Using perl Syntax Highlighting
- #!/usr/bin/perl
- my($dbh,$sth);
- $dbh = ConectarDB->connect();
- $sth = $dbh->prepare('SELECT alffechanac FROM talumnado WHERE alanombre = ? AND alapaterno = ? AND alamaterno = ?') or die("Couldn't prepare statement: " . $dbh->errstr);
- $sth->execute("REBECA","SANCHEZ","GONZALEZ") or die("Couldn't execute statement: " . $sth->errstr);
- my $fecha = $sth->fetchrow_array();
- print '\n $fecha';
- $sth->finish;
- $dbh->disconnect;
Coloreado en 0.001 segundos, usando GeSHi 1.0.8.4
Al ejecutar mi programa me marca lo siguiente:
Using text Syntax Highlighting
Can´t locate object method connect via package ConectarDB (perhaps you forgot to load ConectarBD?) at line 5
Estoy utilizando Perl Express bajo Windows.