Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^5: replicating the command 'unset LIBPATH' in perl

by Anonymous Monk
on May 18, 2010 at 07:00 UTC ( [id://840454]=note: print w/replies, xml ) Need Help??


in reply to Re^4: replicating the command 'unset LIBPATH' in perl
in thread replicating the command 'unset LIBPATH' in perl

This should work
#!/usr/bin/perl -- BEGIN { unless( $ENV{ +__FILE__ } eq __FILE__ ){ delete $ENV{LIBPATH}; $ENV{ +__FILE__ } = __FILE__; exec $^X, __FILE__, @ARGV; # relaunch without LIBPATH } } ...

Replies are listed 'Best First'.
Re^6: replicating the command 'unset LIBPATH' in perl
by JavaFan (Canon) on May 18, 2010 at 07:35 UTC
    That can be simplified to:
    BEGIN { if (exists $ENV{LIBPATH}) { delete $ENV{LIBPATH}; exec $^X, __FILE__, @ARGV; } }
      Thanks gents - I now feel like the beginner I am!

      But....what is __FILE__?

        Its not a secret :) __FILE__ site:perldoc.perl.org The special literals __FILE__, __LINE__, and __PACKAGE__ represent the current filename, line number, and package name at that point in your program.
        $ perl -e"die __FILE__" -e at -e line 1. $ echo die __FILE__ > thefileis $ perl -e"die __FILE__" -e at -e line 1. $ echo die __FILE__ > thefileis $ perl thefileis thefileis at thefileis line 1. $ perl D:\thefileis D:\thefileis at D:\thefileis line 1. $

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://840454]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-04-19 15:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found