perl - use of perl @ARGV
问题描述
In a perl application I'm passing variables around with @ARGV. When there were always two variables and always the same two no problems. Now it's got more complicated so I need to "empty" @ARGV before adding to it. So I thought this would work:
foreach (@ARGV)
{
pop @ARGV;
}
It doesn't. When there are four elements it removes only two. Any idea why that should be? Or any other way of emptying it?
解决方案
In a perl application I'm passing variables around with @ARGV.
This is a poor design and should be avoided. If you need to pass values around, use function arguments, or at least your own global variable. Don't (ab)use a special variable for this.
Now it's got more complicated so I need to "empty" @ARGV before adding to it.
If you want to make an array empty, assign an empty list to it:
@ARGV = ();
推荐阅读
- logistic-regression - 二元逻辑回归:总体百分比没有增加的显着性?
- python - 在 python 中加载 COM dll
- excel - 从行开始查找要粘贴的列
- git - 为什么git说我的文件在存储库之外?
- c# - 有什么方法可以在不使用继承的情况下将属性带入类?
- django - 使用 Django digitalocean Spaces 请求的资源上不存在“Access-Control-Allow-Origin”标头
- c++ - 从记录集中读取文本字段返回“?”
- java - 具有数组比较嵌套循环的布尔方法如何修复
- powershell - Get-ChildItem -File -Exclude 问题
- shell - Jenkins 如何从过去 10 次执行中复制报告文件