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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:08:57+00:00 2026-05-16T16:08:57+00:00

All over the place, especially in DBI, I see this message come up all

  • 0

All over the place, especially in DBI, I see this message come up all the time. It’s confusing, because the first thing that comes to mind is that the arguments I’m passing the function are set to undef (or something similar), but it’s clearly not the case.

Given a module and a corresponding script…

Module: ./lib/My/Module.pm

package My::Module;

use strict;
use warnings;

sub trim {
    my $str = shift;
    $str =~ s{ \A \s+ }{}xms; # remove space from front of string
    $str =~ s{ \s+ \z }{}xms; # remove space from end of string
    return $str;
}

Script: ./test.pl

#!/usr/bin/perl

use strict;
use warnings;
use My::Module qw(trim);

print $My::Module->trim( " \t hello world\t \t" );

I get back the error message

Can’t call method “trim” on an undefined value at ./text.pl line 7.

Infact, if I call $My::Module->notamethod( "hello world" ); it gives a similar error.

What’s wrong with the above script/module?

What is that error Can't call method “X” on an undefined value at ${SOMEFILE} line ${SOMELINE} really saying?
Does this refer to the context of the method call (passed here to print), or the context of the arguments?

  • 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-16T16:08:57+00:00Added an answer on May 16, 2026 at 4:08 pm

    That syntax is looking for an object or classname in the variable $My::Module and calling its trim method, but that variable is undefined.

    Instead, you want to just say print My::Module::trim( " \t hello world\t \t" ); to call the My::Module::trim() function.

    From the use line, it looks like you are trying to import trim() into the local package so you can just call it without the My::Module:: qualification, but your module doesn’t look like it is set up to support exporting.

    In your regexes, the /s and /m flags don’t have any effect – they only change what ., ^, and $ match, and you don’t use any of those.

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

Sidebar

Related Questions

I have code that all over the place(probably 20-30 instances) does this: <widget>.setVisible((condition ==
This is a question that seems to be floating around all over the place,
I see JRE all over the place, but i can not be sure which
I've been searching all over the place and just don't see anyone doing it
I keep getting this error all over the place where I only have jquery
I see some frameworks like Django using unicode all over the place so it
I've seen this all over the place on stack overflow, but everyone else's solution
I've found this all over the place in this code: public enum Blah: int
I have a project that is currently all over the place and i'm thinking
I am working on a projects that is kind of all over the place.

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.