小编Wil*_*ess的帖子

包含'x'但不包含'y'的Unix grep正则表达式

我需要一个包含unix grep的单行正则表达式,包括alpha,但不包含beta.

grep 'alpha' <> | grep -v 'beta'
Run Code Online (Sandbox Code Playgroud)

regex unix grep regex-negation

47
推荐指数
3
解决办法
5万
查看次数

在5.6.x之后,Perl的-w警告开关是否已弃用?

我在Simon Cozens的书"Beginning Perl"中读到-w开关警告将会被弃用.这是真的还是继续使用-w而不是"使用警告"仍然可以.

perl perl5

8
推荐指数
1
解决办法
552
查看次数

GNU-make检查列表/数组中是否存在元素

我在make文件中定义了一个列表,用户应该设置一个我需要在此列表中找到的环境变量.有没有办法使用gnu make来做到这一点?在开始构建任何目标之前,我想在任何配方之外执行此操作.这是一个QA检查,以确保用户设置env.变量到范围/列表中的值.

在终端上:

setenv ENV_PARAM x
Run Code Online (Sandbox Code Playgroud)

在Makefile中:

PARAMS := a b c

if ${ENV_PARAM} exists in $(PARAMS)
  true
else
  false
endif
Run Code Online (Sandbox Code Playgroud)

@MadScientist的答案有效.有没有办法用foreach循环包装if块来测试多个参数?

KEYS    := PARAMS FACTORS
PARAMS  := a b c
FACTORS := x y z

foreach v in ($(KEYS)) {
  ifneq ($(filter $(ENV_$(v)),$(v)),)
    $(info $(ENV_$(v)) exists in $(v))
  else
    $(info $(ENV_$(v)) does not exist in $(v))
  endif
}
Run Code Online (Sandbox Code Playgroud)

arrays element list exists gnu-make

8
推荐指数
1
解决办法
5364
查看次数

如何在Perl中的doc文档中打印BOLD文本?

我正在使用此处的doc为用户打印使用情况消息.有没有办法打印类似于unix上的手册页的特定单词BOLD.我在Unix上使用它.有没有办法在这里使用Term :: ANSIColor(或其他方式?)?

perl text heredoc bold

4
推荐指数
2
解决办法
4471
查看次数

Grep a YAML file in Perl

Are there any modules in Perl which can grep an arbitrary hierarchy in a yaml file - just like ygrep in python? Or code which can do that? I tried googling but didn't find any resources/pointers for it. I have been trying since a few hours without much luck.

perl grep yaml path hierarchy

4
推荐指数
1
解决办法
266
查看次数

fork in perl但从子进程中的系统调用中获取退出状态

我所做的:

  1. 对cgi脚本进行ajax调用.
  2. Cgi脚本分叉,但父母立即返回响应消息.
  3. 子进行系统调用但需要退出代码和任何错误消息.

伪代码:

$SIG{CHLD} = ‘IGNORE’; # or waitpid($pid,0) in the parent process
$pid = fork();
if($pid == 0)
{
    close STDOUT; # So that the parent sends the response to the client right away.

    @errorMsgs = qx(tar up big directories over 50G…); # This can go on for a few minutes.

    if($? ==0) { Send a ‘success’ email } # Is always false ($? == -1)

    else { Send a ‘failure’ email }
}
elsif($pid){ sendResponse; waitpid($pid,0) …
Run Code Online (Sandbox Code Playgroud)

ajax perl fork exit qx

3
推荐指数
1
解决办法
1593
查看次数

标签 统计

perl ×4

grep ×2

ajax ×1

arrays ×1

bold ×1

element ×1

exists ×1

exit ×1

fork ×1

gnu-make ×1

heredoc ×1

hierarchy ×1

list ×1

path ×1

perl5 ×1

qx ×1

regex ×1

regex-negation ×1

text ×1

unix ×1

yaml ×1