Page 1 of 1

Perl in Xampp

PostPosted: 15. December 2020 23:45
by chalancito
ok,
I installed XAMPP, configurated my VirualHosts... until now all is working: Apache->PHP->MySQL(Mariadb), also my virtualhosts.
Now i want to run my Perl scripts but I don't know where to put them (Directory) in order to use my DBs from my Perl scripts.
Please give me the some orientation about this. Thanks in advance.

Re: Perl in Xampp

PostPosted: 16. December 2020 00:33
by Altrea
You can place your perl scripts in any by Apache requestable folder you want.

Some examples:
/opt/lampp/cgi-bin/
/opt/lampp/htdocs/projectxy/
/opt/lampp/vhosts/vhost1/

If you want to place them inside your virtual host and the virtual host is not a subdirectory of htdocs, then you need to add the Directory Option ExecCGI by yourself.
For cgi-bin and htdocs this is already given in the default configuration of XAMPPs Apache.

Re: Perl in Xampp

PostPosted: 16. December 2020 01:29
by chalancito
Thank you very much. I'll proceed. My virtual hosts are inside htdocs then all must be running smoothly.

Re: Perl in Xampp

PostPosted: 03. January 2021 02:11
by chalancito
ok, after trying a script of my own i got many errors, then i went to the basics and got an example from internet.
First I got an error:
install_driver(mysql) failed: Can't locate DBD/mysql.pm in @INC...
then i found a tip about adding a use lib with the route to the DBD/mysql and got this error:
install_driver(mysql) failed: Attempt to reload DBD/mysql.pm aborted. Compilation failed in require at (eval 15) line 3. at /opt/lampp/htdocs/dummy2/ejbdcon1.pl line 15.
the script i try to get working is just this:
#!/usr/bin/perl
use strict;
use warnings;
use lib '/usr/lib/x86_64-linux-gnu/perl5/5.30/';
use DBI;
print "Perl MySQL Connect Demo\n";
# MySQL database configuration
my $dsn = "DBI:mysql:bd_nfl";
my $username = "root";
my $password = '';
# connect to MySQL database
my %attr = ( PrintError=>0, RaiseError=>1);
# turn off error reporting via warn()
# turn on error reporting via die()
my $dbh = DBI->connect($dsn,$username,$password, \%attr);
print "Connected to the MySQL database.\n";

I don't know now how to go ahead, your tips will be appreciated

Re: Perl in Xampp

PostPosted: 10. March 2023 15:23
by okaybmd
XAMPP is now using MariaDb instead of MySQL, so you need to use:
my $dsn = "DBI:MariaDB:...