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 3346866
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:21:16+00:00 2026-05-18T01:21:16+00:00

this is my first foray into subclassing with perl and I am wondering why

  • 0

this is my first foray into subclassing with perl and I am wondering why I am getting this simple error…

“Can’t locate object method “prepare” via package “WebDB::st” at /home/dblibs/WebDB.pm line 19.”. It seems to find the module WebDB ok, but not the prepare subroutine in ::st
First here’s my package (both packages are in one file, WebDB.pm)

package WebDB;
use strict;
use DBI;

sub connect {
    my $dbh = (DBI->connect ("DBI:mysql:test:127.0.0.1", "root","",
                    { PrintError => 1, RaiseError => 0 }));
    return bless $dbh, 'WebDB::st';
}

package WebDB::st;
our @ISA = qw(::st);
sub prepare {
    my ($self, $str, @args) = @_;
    $self->SUPER::prepare("/* userid:$ENV{USER} */ $str", @args);
}


1;

I also tried replacing the “our @ISA = qw(;;st)” with “use base ‘WebDB'” and same problem.
I’m thinking it’s probably something very simple that I’m overlooking. Many thanks! Jane

  • 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-05-18T01:21:16+00:00Added an answer on May 18, 2026 at 1:21 am

    Subclassing DBI has to be done just right to work correctly. Read Subclassing the DBI carefully and properly set RootClass (or explicitly call connect on your root class with @ISA set to DBI). Make sure you have WebDB::st subclassing DBI::st and a WebDB::db class subclassing DBI::db (even if there are no methods being overridden). No need to rebless.

    Avoid using base; it has some unfortunate behavior that has led to its deprecation, particularly when used with classes that are not in a file of their own.
    Either explicitly set @ISA or use the newer parent pragma:

    package WebDB;
    use parent 'DBI';
    ...
    package WebDB::db;
    use parent -norequire => 'DBI::db';
    ...
    package WebDB::st;
    use parent -norequire => 'DBI::st';
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my first foray into Java, so forgive me if this is simple,
This is my first foray into UDP socket programming. Without getting into the details
This is my first foray into designing two versions of images for retina or
I've worked with CakePHP 1.3, but this is my first foray into CakePHP 2.0
This is my first foray into the world of Objective-c images and I immediately
This is my first foray into using an MVC construct (CodeIgniter). I'm hoping someone
This is my first foray into shell scripting so if i'm asking a very
I'm not a newb to JavaScript but this is my first foray into Acrobat
I'm not an expert on this, this is my first foray into creating a
I'm a (near complete) beginner, and this is my first foray into encryption -

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.