Hey everyone,
I am very new to Perl and I am having an issue with the following code:
**************************************************************
package GUI:B;
use strict;
use DBI;
use vars qw(@ISA @EXPORT);
use Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(dbConnect query);
# dbConnect - connect to the database, get the database handle
sub dbConnect {
# Read database settings from config file:
my $dsn = "dbi:mysql:test:localhost:3306";
my $dbh = DBI->connect( $dsn,'test','test',{ RaiseError => 1 });
return $dbh;
}
# query - execute a query with parameters
# query($dbh, $sql, @bindValues)
sub query {
my $dbh = shift;
my $sql = shift;
my @bindValues = @_; # 0 or serveral parameters
my @returnData = ();
# issue query
my $sth = $dbh->prepare($sql);
if ( @bindValues ) {
$sth->execute(@bindValues);
} else {
$sth->execute();
}
if ( $sql =~ m/^select/i ) {
while ( my $row = $sth->fetchrow_hashref ) {
push(@returnData, $row);
}
}
# finish the sql statement
$sth->finish();
return @returnData;
}
__END__
**************************************************************
The perl logs are displaying the following error:
*** 'C:\inetpub\ log message at: 2012/05/02 16:05:21
Precompiler: Fatal Eval Error:
Package:[PerlEx:recompiler::c_::inetpub::wwwroot::module::db2_pm]
File:[C:\inetpub\wwwroot\module\db2.pm]
Error:[Missing right curly or square bracket at C:\inetpub\ line 56, at end of line
syntax error at C:\inetpub\ line 56, at EOF
]
I can't seem to resolve this one, I have went through each bracket in this code and there doesn't seem to be anything missing.
I will provide my system info if it helps at all:
OS: Windows 7 64 bit
Perl version: ActivePerl version 5.14.2.1402 (x86)
I have set this up with IIS 7, and it perl seems to work fine, it's just this module that is giving me problems.
Any help will be appreciated.
I am very new to Perl and I am having an issue with the following code:
**************************************************************
package GUI:B;
use strict;
use DBI;
use vars qw(@ISA @EXPORT);
use Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(dbConnect query);
# dbConnect - connect to the database, get the database handle
sub dbConnect {
# Read database settings from config file:
my $dsn = "dbi:mysql:test:localhost:3306";
my $dbh = DBI->connect( $dsn,'test','test',{ RaiseError => 1 });
return $dbh;
}
# query - execute a query with parameters
# query($dbh, $sql, @bindValues)
sub query {
my $dbh = shift;
my $sql = shift;
my @bindValues = @_; # 0 or serveral parameters
my @returnData = ();
# issue query
my $sth = $dbh->prepare($sql);
if ( @bindValues ) {
$sth->execute(@bindValues);
} else {
$sth->execute();
}
if ( $sql =~ m/^select/i ) {
while ( my $row = $sth->fetchrow_hashref ) {
push(@returnData, $row);
}
}
# finish the sql statement
$sth->finish();
return @returnData;
}
__END__
**************************************************************
The perl logs are displaying the following error:
*** 'C:\inetpub\ log message at: 2012/05/02 16:05:21
Precompiler: Fatal Eval Error:
Package:[PerlEx:recompiler::c_::inetpub::wwwroot::module::db2_pm]
File:[C:\inetpub\wwwroot\module\db2.pm]
Error:[Missing right curly or square bracket at C:\inetpub\ line 56, at end of line
syntax error at C:\inetpub\ line 56, at EOF
]
I can't seem to resolve this one, I have went through each bracket in this code and there doesn't seem to be anything missing.
I will provide my system info if it helps at all:
OS: Windows 7 64 bit
Perl version: ActivePerl version 5.14.2.1402 (x86)
I have set this up with IIS 7, and it perl seems to work fine, it's just this module that is giving me problems.
Any help will be appreciated.