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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:33:40+00:00 2026-05-31T01:33:40+00:00

In perl, we can do: use lib LIST; to include a list of paths

  • 0

In perl, we can do:

use lib LIST;

to include a list of paths in @INC. Similarly, we can do:

use if CONDITION, MODULE => ARGUMENTS;

to include a module conditionally.

Is it possible to do a mix of both, something like

use lib if CONDITION, LIST;

to include a list of paths conditionally. This doesn’t seem to work.

Edit:
Sorry, but I can’t still get it working. This is how I am doing but its not working. Can you please suggest what is wrong?

use Data::Dumper;

BEGIN {
    my $env=$ENV{'ENV'};
    use if $env eq 'OLD', lib => '/home/vivek/OLD';
    use if $env eq 'NEW', lib => '/home/vivek/NEW';
}

print Dumper \@INC;
  • 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-31T01:33:41+00:00Added an answer on May 31, 2026 at 1:33 am

    if is a separate module (strictly a pragma) that takes the rest of the line as parameters. lib is also a separate pragma. Take a look at the documented syntax use if CONDITION, MODULE => ARGUMENTS and you will see that what you should be writing is

    use if CONDITION, lib => LIST;
    

    which works fine.

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

Sidebar

Related Questions

The Term::Size-module jumbles up the encoding. How can I fix this? #!/usr/bin/env perl use
Any suggestion how I can document my Perl code? What do you use and
I know how to use Perl's Getopt::Long, but I'm not sure how I can
Can someone suggest a good module in perl which can be used to store
I am trying to create my own Perl module in /usr/local/lib/perl I have the
Perl is complaining that it can't find a module that is right there in
I'm creating a web application that requires the use of the perl module Crypt-SSLeay.
We use MyCPAN::App::DPAN (Version 1.28) just like in Question: How can I manage Perl
I'm trying to use the Tenjin module but it fails because it can't find
I'm just curious if when writing PL/Perl functions if I can have a use

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.