Perl 的 FindBin 行为的改变
我有一组使用 FindBin 模块的 Perl 脚本。脚本使用一些数据文件,并希望在 $FindBin::Bin/../share/somedir/ 中找到它们。我正在自定义安装,因此这些文件现在存在于 /some/other/share/dir/
中。有什么方法可以使用环境变量之类的东西来自定义 FindBin 的行为吗?
I've got a collection of Perl scripts which use the FindBin module. There are some data files which the scripts use, and are expecting to find them in $FindBin::Bin/../share/somedir/
. I'm customizing the installation so those files now exist is /some/other/share/dir/
. Is there any way to customize the behaviour of FindBin with something like, say, an environment variable?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您不能使用 FindBin 模块解决这个问题,因为它旨在解决特定问题:定位原始 perl 脚本的目录。
您应该实现自己的模块来获取配置参数。这看起来像:
这将允许您在一处控制所有配置路径。但您需要更改现有代码。
I don't think you can solve this problem with
FindBin
module, because it's designed to solve particular problem: locate directory of original perl script.You should implement your own module to getting configuration parameters. This can look like:
This will allow you to control all your configuration path in one place. But you'll need to change exists code.