#Perl #HTML #Database #Query

The Mason approach is based on MVC, therefore you need to define the database connection within your Base.mc as follows:

my $conn = DATABASE_NAME::DBI->conn();
my $sconn = DATABASE_NAME::DBI->session_conn();

Afterwards e.g. in your index.mi you need to define another init section in which you can execute your actual query to gather informations from your Database:

my $dbh = Ws21::DBI->dbh();
my $sth;
my @articles;
if (!defined $.search) {

Then you are able to call this information with perl from within your html code section like this:

% for my $article (@articles) {
% }

For this call it is very important that you start the perl section with % at the very beginning of the line. If it will be started with leading spaces or tabs, it will throw an exception.




How to use Pearl within a HTML based on Mason

I would like to use perl within my HTML file to get some informations from my Database. Apparently I am not able to get things working since the error messages are confusing me a lot. Could someone show me how I am able to call the information of my Database with perl ?
Subscribe to #Perl #HTML #Database #Query