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

  • Home
  • SEARCH
  • 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 7953415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:09:18+00:00 2026-06-04T03:09:18+00:00

I wrote a perl module: package sql; use strict; use XML::Simple; use DBI; use

  • 0

I wrote a perl module:

package sql;
use strict;
use XML::Simple;
use DBI;
use DBD::mysql;

require Exporter;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(DBImport DataFill);
our @EXPORT = qw(DBImport DataFill);

our $dbh;

sub DBConnect() {
    my $platform = "mysql";
    my $database = "databasename";
    my $host = "localhost";
    my $user = "user";
    my $pw = "password";
    my $dsn = "dbi:mysql:$database:localhost";
    $dbh = DBI->connect($dsn, $user, $pw);
    $dbh->do('SET NAMES utf8');
    return $dbh;
}

sub Query($) {
    my $sth = $dbh->prepare(shift);
    $sth->execute;
    while (my $ref = $sth->fetchrow_hashref()) {
        print $ref->{'email'};
    }
    $sth->finish();
}

BEGIN{
    $dbh = &DBConnect();
}

END{
    $dbh->disconnect();
}
1;

and i tried use it:

#!/usr/bin/perl
use strict;
use CGI qw/:standard/;
use CGI::Carp qw/fatalsToBrowser warningsToBrowser/;
use sql;

&Query("SELECT * FROM users");

but it don’t working.

error message: Undefined subroutine &main::Query called at /var/www/domains/gabordx.tauri.hu/www/main.pl line 7. -> “&Query(“SELECT * FROM users”);”

What is the problem with?

Thanks!

  • 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-04T03:09:19+00:00Added an answer on June 4, 2026 at 3:09 am

    You need to export Query as well, like this:

    our @EXPORT_OK = qw(Query DBImport DataFill);
    our @EXPORT = qw(Query DBImport DataFill);
    

    Otherwise you should refer it through sql package, like this

    sql::Query("SELECT * FROM users");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a Perl script that it makes some SQL queries in a table
I have a Perl script I wrote for my own personal use that fetches
If I wrote something in plperlu, and it used a Perl module (e.g. MyModule::Foo),
I am trying to use perl's YAML::XS module on unicode letters and it doesn't
Newbie here, I am trying to use Bioperl module in the perl environment. My
Using perl's XML::SAX module I'm parsing (x)html templates, and as a result am simply
I wrote a simple shell script to get the version of Perl modules installed
I have been trying to use the module Win32::SerialPort in perl 5.10 (perhaps it
I am searching a Perl module to write (SMTP) and read (IMAP) e-mails. Which
I wrote a perl script a while ago which logged into my online banking

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.