首页 \ 问答 \ 这个Perl脚本实现了什么?(What does this Perl script achieve?)

这个Perl脚本实现了什么?(What does this Perl script achieve?)

我正在阅读由别人编写的Perl脚本,我对Perl不太熟悉,所以有人会告诉我前三行是干什么的?

my $ref = do($filename);
$ref != 0 or die "unable to read/parse $filename\n";
@varLines=@{$ref};
foreach $ord (@varLines)
{
    # code here
}

这是在获取命令行参数设置$filename后程序的开始

被传递给这个脚本的文件的格式是

[
  {
    "Key1" => "val1",
    "key2" => " "A",
  },
  {
    "Key3" => "val2",
    "key4" => " "B",
  },
]

I was going over a Perl script written by someone else and I am not too familiar with Perl so could someone let me know what do the first three lines do?

my $ref = do($filename);
$ref != 0 or die "unable to read/parse $filename\n";
@varLines=@{$ref};
foreach $ord (@varLines)
{
    # code here
}

This is in the beginning of the program after the $filename is set with getting the commandline arguments

The format of the file being passed to this script is

[
  {
    "Key1" => "val1",
    "key2" => " "A",
  },
  {
    "Key3" => "val2",
    "key4" => " "B",
  },
]

原文:https://stackoverflow.com/questions/1744340
更新时间:2022-03-12 10:03

最满意答案

您可以使用windows提供的命令: caclsicacls

只读 cacls

$ cacls "$file_path" //E //P Everyone:N 1>/dev/null
$ cacls "$file_path" //E //G Everyone:R 1>/dev/null

只写cacls

$ cacls "$file_path" //E //P Everyone:N 1>/dev/null
$ cacls "$file_path" //E //G Everyone:W 1>/dev/null

第一行删除所有权限。 第二行添加“读”或“写”

如果您不使用Windows XP,则可以使用icacls

  • 只读icacls "$file_path" //grant :r Everyone:R 1>/dev/null
  • 只写icacls "$file_path" //grant :r Everyone:W 1>/dev/null

有关这些命令的更多信息:


You can use the commands provided by windows: cacls and icacls

Read-Only with cacls

$ cacls "$file_path" //E //P Everyone:N 1>/dev/null
$ cacls "$file_path" //E //G Everyone:R 1>/dev/null

Write-Only with cacls

$ cacls "$file_path" //E //P Everyone:N 1>/dev/null
$ cacls "$file_path" //E //G Everyone:W 1>/dev/null

The first line removes all rights. The second lines add either "Read" or "Write"

If you are not using Windows XP, you can use icacls instead:

  • Read-only: icacls "$file_path" //grant :r Everyone:R 1>/dev/null
  • Write-only: icacls "$file_path" //grant :r Everyone:W 1>/dev/null

More information on these commands:

相关问答

更多
  • MSYS是windows的.dll/.exe等文件的库文件, 库文件就是帮你实现了某些功能的库函数的封装,你可以在你的程序中调用这些函数,然后连接一下就可以了。 区别: cygwin/gcc和MinGW都是gcc在windows下的编译环境 cygwin/gcc完全可以和在linux下的gcc化做等号,这个可以从boost库的划分中可以看出来端倪,cygwin下的gcc和linux下的gcc完全使用的是相同的Toolsets。 所以完全可以和linux一起同步更新gcc版本,而不用担心问题,并且在cygwi ...
  • 传统上MSYS bash一直较差,但主要是因为Cygwin仍处于积极发展阶段,而MSYS则没有。 MSYS从Cygwin 1.3.3版分出,并且从未重新同步,而MSYS2则定期与Cygwin项目重新同步。 我们没有像包管理器那样的“甜蜜的牧师”,我们直接重新编译Arch Linux的pacman包管理器,就像我们可以实现的那样。 MSYS2没有cygwin.dll,但它确实有msys-2.0.dll,它可以做同样的事情(还有一些更多)。 具体而言,看起来像路径和PATH环境的参数。 运行Windows本机软 ...
  • 看起来好像是在尝试使用Bash运行“批处理”文件。 这不行。 虽然批处理文件将rem解释为注释,但Bash只是认为它是一个命令并尝试运行它。 我的建议是将其重写为Bash脚本,也许这可能是一个起点。 It looks as though you are trying to run a "Batch" file using Bash. This will not work. While Batch file interprets rem as a comment, Bash simply thinks it ...
  • 编辑(2年以后:2014年10月) 约翰内斯·辛德林 刚刚解释 (2014年10月), msysgit被淘汰 : 我们现在拥有一个重量轻的Git for Windows SDK ,它基本上是通过包管理器mingw-get管理的标准MinGW / MSys系统。 我们决定逐渐删除名称“msysGit”(以及同名的GitHub组织) ,并在Git for Windows (使用相应的GitHub组织)上使用名称“Git for Windows”作为安装程序对于面向Git for Windows开发人员的开发环境 ...
  • 鉴于错误消息与SSL相关,看起来SSL没有安装在cygwin中。 重新运行setup.exe并回答提示以返回“ Select Packages屏幕。 在“搜索”框中输入SSL 打开Libs部分并选择所需的库。 或者,您可以从Net部分安装整个openssl包,并让cygwin安装所有必需的依赖项。 I solved the SSL errors by adding -lsslto the gcc line. Final gcc line: $ gcc -Wall -Imosquitto-1.1.3/lib/ ...
  • 您可以使用windows提供的命令: cacls和icacls 只读 cacls $ cacls "$file_path" //E //P Everyone:N 1>/dev/null $ cacls "$file_path" //E //G Everyone:R 1>/dev/null 只写与cacls $ cacls "$file_path" //E //P Everyone:N 1>/dev/null $ cacls "$file_path" //E //G Everyone:W 1>/dev/nu ...
  • 来自C#3.0规范: 将属性指定为自动实现的属性时,将为该属性自动提供隐藏的后备字段,并且实现访问器以读取和写入该后备字段。 由于支持字段不可访问,因此只能通过属性访问器读取和写入。 这意味着自动实现的只读或只写属性没有意义,并且是不允许的。 但是,可以以不同方式设置每个访问者的访问级别。 因此,具有私有支持字段的只读属性的效果可以像这样模仿: public class ReadOnlyPoint { public int X { get; private set; } public int Y { ...
  • 许多问题,这里有一些答案: 你的.emacs可以存在很多地方,这取决于, 在这里阅读。 简而言之,请尝试Cx Cf .emacs ,或者检查变量'user-init-file ( Ch v user-init-file )的值。 我认为你想要的命令是这样的: (require 'comint) ; this does require comint (defun cygwin () "do what i want for cygwin" (interactive) (let ((buffer (g ...
  • 我不知道任何可以可靠地传达这些信息的环境变量,但是uname -s的输出应该告诉你。 I don't know of any environment variable which will reliably convey this information, but the output from uname -s should tell you.
  • 程序中不需要更改对象的部分应该只是使用const引用,并将非变异成员函数标记为const。 class FooR { public: int read() const { return x; } void mutate(int nx) { x = nx; } private: int x; }; void f1(FooR const& obj) { int x = obj.read(); // cannot use obj.mutate(x+1); } void m ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)