title: How to change @INC lib contents by using no lib command in PERL
body: <pre><code>if (@arr =~ /env1/) #checking enviroment  
  {
     # Want to flush the @INC contents using below no lib
     # --&gt; Command before the perl get the libraries of my choice at the time of compilation 
  
     no lib "//First/lib/"; #flush INC  
     no lib "//Second/lib/"; #flush INC  
     print log1 "INC before current- @INC\n";
  
     #set library of my choice with either syntax
     BEGIN{ unshift @INC, "//Third/lib/" };                                    
     # or                                      
     use lib "//third/lib/";
  
     print log1 "INC after- @INC\n";  
     print log2 "INC after- %INC\n";  
     print log3 map {"$_ =&gt; $INC{$_}\n"} keys %INC; 
  
     use DirHandle;  
     use File::Find;  
     use File::Copy;  
  
     print map {"$_ =&gt; $INC{$_}\n"} keys %INC;
  }
  </code></pre>
  
  <p>I  want to know the above thing can be achieved in a simpler way. Do I need to include any Perl modules to use the (no lib and use lib commands). This is a requirement due to script running in multiple enviroment and when one of the enviroments is down the script stops running. I want to achieve this by passing the libraries of my choice to be used by perl. </p>
  
  <p>Suggestions are welcome.</p>
  
  <hr>
  
  <p><strong>Edit:</strong>
  Here's the actual code.</p>
  
  <pre><code>if (@temp[arr_index]=~ /env1/) #enviroment 1
                        {              
  
                       BEGIN{ unshift @INC, "//server1/lib/" }; #server 1 for same app lower enviroment 1
                       BEGIN{ unshift @INC, "//server2/lib/" }; #server 2 for same app lower enviroment 1
  
                                      use File::Copy; 
  
                      }
  
      elsif (@temp[arr_index]=~ /env2/) #enviroment 2
  
      {
                      BEGIN{ unshift @INC, "//server1/lib/" }; #server 1 for same app lower enviroment 2
                      BEGIN{ unshift @INC, "//server2/lib/" }; #server 2 for same app lower enviroment 2
  
                                      use File::Copy;
      }
  
  
      elsif (@temp[arr_index]=~ /env3/) #enviroment 3
  
      {
                      BEGIN{ unshift @INC, "//server1/lib/" }; #server 1 for same app lower enviroment 3
                      BEGIN{ unshift @INC, "//server2/lib/" }; #server 2 for same app lower enviroment 3
  
                                      use File::Copy;
      }
  </code></pre>
  
  <p><code>@INC</code> - Having <code>@INC</code> the values same for all enviroments which is causing issue. Hope the above adds some clarity to your understanding . THANKS.</p>