Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8737995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:38:47+00:00 2026-06-13T10:38:47+00:00

So I have a cgi script, #!/usr/bin/perl -T use strict; use warnings; use DBI;

  • 0

So I have a cgi script,

#!/usr/bin/perl -T

use strict;
use warnings;
use DBI;
use WebEngine;


my $dbh = DBI->connect('DBI:mysql:database', $username, $password)
    || die "Could not connect to database: $DBI::errstr";

my $we = WebEngine->new($dbh)
    or die("Failed to instantiate WebEngine object:\n$!\n");

$userID = $we->register("MyUsername", $dbh);

This script creates a database handler and then uses a module I made to deal with most of the back-end of the site to register a username and return a userID number.

I have three questions about this.

  • Does creating this $dbh in this script increase performance by keeping a database connection open?

  • Could I put the $dbh in my module and not fear being inefficient?

  • Is there a security benefit to keeping the $dbh (and the associated info(I keep my pass in plain text in the code; is that bad?)) in the module that is not directly interacted with through my website?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T10:38:48+00:00Added an answer on June 13, 2026 at 10:38 am

    Does creating this $dbh in this script increase performance by keeping
    a database connection open?

    Could I put the $dbh in my module and not fear being inefficient?

    Generally, you want to minimize the length of time that a database connection is open. Having lots of connections open at the same time hurts performance. The longer you keep a connection open, the more connections you will accumulate when lots of people use your site at the same time.

    On the other hand, disconnecting and reconnecting many times could also hurt performance.

    If you expect a large traffic volume on your site, the best solution is to implement connection pooling. This keeps a number of active connections open and available, but doesn’t tie them to a particular user. Here is a discussion of MySQL connection pooling with Perl. If you implement it this way, then you would want to open a connection for the minimum time possible. It will be efficient, because it isn’t a "real" open under the hood–just an assignment of an already-open connection.

    Is there a security benefit to keeping the $dbh (and the associated
    info(I keep my pass in plain text in the code; is that bad?)) in the
    module that is not directly interacted with through my website?

    If the module is located in a non-web-accessible folder, that might be a slight benefit. Really, though, you should not be storing a password in plain text. Here is a discussion of some other options.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following, simplest Perl CGI script: use strict; use warnings; use CGI();
I am using the following script: #!/usr/local/bin/perl -wT use strict; use warnings; print Content-type:
I have a perl script: #!/usr/bin/perl -w use DateTime; use Expect; use IO::Pty; use
I have this Perl script sitting in the cgi-bin folder of my Apache server:
I have a perl.cgi file which has the content: #!/usr/bin/perl print Content-type: text/html\n\n; print
I have a perl cgi script that's fairly resource intensive (takes about 2 seconds
I currently have a Perl CGI script that parses incoming XML requests using XML::Simple
I have a script that's written in perl, and executed as CGI. It works
I have written a Perl script to read the configuration file and create CGI
I have an AWK script which looks like #!/usr/bin/gawk -f BEGIN { print myVar;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.