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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:26:56+00:00 2026-06-01T10:26:56+00:00

Based on the answer provided here , I am attempting to validate whether or

  • 0

Based on the answer provided here, I am attempting to validate whether or not a perl module is installed.
For this, I have:

# &getYN and &prompt are only included here for completeness
sub getYN {
    unless ( $autoyes =~ /[Yy]/ ) {
        my ( $prompt, $default ) = @_;
        my $defaultValue = $default ? "[$default]" : "";
        print "$prompt $defaultValue: ";
        chomp( my $input = <STDIN> );
        return $input ? $input : $default;
    } else {
        return "Y";
    }
}

sub prompt {
    my ( $prompt, $default ) = @_;
    my $defaultValue = $default ? "[$default]" : "";
    print "$prompt $defaultValue: ";
    chomp( my $input = <STDIN> );
    return $input ? $input : $default;
}

&chklib("RRDTool::OO");
sub chklib {
    my $lib = shift;
    eval { require $lib; };
    if ($@) {
        print "You are missing a required Perl Module: $lib\n";
        my $ok = &getYN( "Shall I attempt to install it for you?", "y" );
        if ( $ok =~ /[Yy]/ ) {
            require CPAN;
            CPAN::install($lib);
        } else {
            print "Installation requires $lib\n";
            exit;
        }
    }
}

This runs as expected, but for some reason, the eval returns that I don’t have RRDTool::OO installed, when, in fact, I do.

If I create an empty file and run:

# File foo.pl
use strict;

$| = 1; 

use RRDTool::OO;

Then I get no errors.

But when I run the first file with print $@;, it returns:

Can't locate RRDTool::OO in ...

What am I doing wrong?

  • 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-01T10:26:57+00:00Added an answer on June 1, 2026 at 10:26 am

    You have to check the result of the eval, like

    if (eval("require xxx;")) {
         print "you have it\n";
    } else {
         print "you don't\n";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is a perplexing issue I have not seen a good answer to on
Based the accepted answer to this question I've setup a NetBeans/tomcat environment. In testing
This is a further question based on this answer: How can I implement a
UPDATE: Solved. Thanks BusyMark! EDIT: This is revised based on the answer below from
this question is based on answer got from another SO question, can be found
I saw variants of this question before, but didn't find answer yet. I have
I am trying to evaluate the answer provided here , and am getting the
This question has been asked here before . The accepted answer was probably obvious
Based on one answer to an earlier post , I'm investigating the possibility of
For the following question, I am looking for an answer that is based on

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.