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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:06:59+00:00 2026-05-26T03:06:59+00:00

Here is the scenario, I have two files: 1. dir/A.pm 2. dir/new_dir/a.t This is

  • 0

Here is the scenario, I have two files:
1. dir/A.pm
2. dir/new_dir/a.t

This is how A.pm looks like:

package A;
use FindBin;
use Test::More;
is (FindBin->again, 'dir', 'got dir');
1;                    

This is how a.t looks like:

use FindBin;
use Test::More qw(no_plan); 
use A;
is (FindBin->again, 'dir/new_dir', 'got dir/new_dir');

So I ran file a.t with perl new_dir/a.t and expect my tests to pass. But this is my test result:

not ok 1 - got dir
#   Failed test 'got fir'
#   at A.pm line 6.
#          got: 'dir/new_dir'
#     expected: 'dir'
ok 2 - got dir/new_dir
1..2

Am I doing anything wrong? I am very new to perl. Please help!!

  • 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-26T03:06:59+00:00Added an answer on May 26, 2026 at 3:06 am

    As Dave Sherohman notes, FindBin is for finding the location of the main script, not individual modules. From the documentation:

    NAME
           FindBin - Locate directory of original perl script
    

    (Admittedly, the documentation does, somewhat confusingly, refer to “modules” in the “KNOWN ISSUES” section, but it doesn’t really mean what you think it means by that.)

    Anyway, if you look at the source with perldoc -m FindBin, you’ll see that FindBin obtains the path to the script from the $0 variable. If you’re interested in finding the location of a module included via use (or require), you should look under %INC instead, something like this:

    package Foo::Bar;
    use File::Spec;
    my ($vol, $dir, $file) = File::Spec->splitpath( $INC{'Foo/Bar.pm'} );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my scenario: I have two MySQL tables: Categories (columns: id, category) Items
Here's the simplified scenario: I have a page with two sections: a search section,
So, Here is my scenario: I have two activity and one service --> all
Classic ASP Request.ServerVariables(LOGON_USER) is returning wrong username. Here is the scenario: I have two
Here is the scenario: I have successfully bound two objects from a native ObjC
Here is the scenario: I have two asp pages. a.aspx is layout and b.aspx
Here is the scenario: I have two radio buttons, 1) for a normal customers
I'm experiencing this error in Django 1.2 admin. Scenario: I have two applications, say
Here's the scenario: I have a public repo A . Bob forks A ,
Here is my scenario: I have an Eclipse project in my desktop in a

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.