微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

FindBin

NAME

FindBin - Locate directory of original perl script

§

SYnopSIS

use FindBin;
use lib "$FindBin::Bin/../lib";

or

use FindBin qw($Bin);
use lib "$Bin/../lib";

DESCRIPTION

Locates the full path to the script bin directory to allow the use of paths relative to the bin directory.

 

This allows a user to setup a directory tree for some software with directories <root>/bin and <root>/lib and then the above example will allow the use of modules in the lib directory without kNowing where the software tree is installed.

 

If perl is invoked using the -e option or the perl script is read from STDIN then FindBin sets both $Bin and $RealBin to the current directory.

 

EXPORTABLE VARIABLES

$Bin           - path to bin directory from where script was invoked
$Script       - basename of script from which perl was invoked
$RealBin      - $Bin with all links resolved
$RealScript  - $Script with all links resolved

 

KNowN BUGS

if perl is invoked as

 

   perl filename

 

and filename does not have executable rights and a program called filename exists in the users $ENV{PATH} which satisfies both -x and -T then FindBin assumes that it was invoked via the $ENV{PATH}.

 

Workaround is to invoke perl as

 

perl ./filename

 

AUTHORS

Graham Barr <[email protected]> Nick Ing-Simmons <[email protected]>

 

copYRIGHT

copyright (c) 1995 Graham Barr & Nick Ing-Simmons. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

 

REVISION

$Revision: 1.4 $

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐