如果替换是在变量中传递的,那么第一个和第二个替换是否相等?
#!/usr/bin/env perl6
use v6;
my $foo = 'switch';
my $t1 = my $t2 = my $t3 = my $t4 = 'this has a $foo in it';
my $replace = prompt( ':' ); # $0
$t1.=subst( / ( \$ \w+ ) /, $replace );
$t2.=subst( / ( \$ \w+ ) /, { $replace } );
$t3.=subst( / ( \$ \w+ ) /, { $replace.EVAL } );
$t4.=subst( / ( \$ \w+ ) /, { ( $replace.EVAL ).EVAL } );
say …Run Code Online (Sandbox Code Playgroud) 做"或死$!" - 参与"关闭$ fh或死$!;" - 行什么好?
#!/usr/bin/env perl
use warnings;
use strict;
my $file = 'my_file';
open my $fh, '<', $file or die $!;
print <$fh>;
close $fh or die $!;
Run Code Online (Sandbox Code Playgroud) 有没有办法获得printf彩色输出?
#!/usr/bin/perl
use warnings;
use strict;
use Term::ANSIColor;
printf "%4.4s\n", colored( '0123456789', 'magenta' );
Run Code Online (Sandbox Code Playgroud)
输出:(仅换行)
我正在搜索Perl模块来编写(SMTP)和读取(IMAP)电子邮件.您会建议使用哪个模块?
#!/usr/bin/env perl
use warnings; use strict;
use 5.012;
use IPC::System::Simple qw(system);
system( 'xterm', '-geometry', '80x25-5-5', '-bg', 'green', '&' );
say "Hello";
say "World";
Run Code Online (Sandbox Code Playgroud)
我试过这个在后台运行xterm-command,但它不起作用:
没有找到shell的绝对路径:&
什么是使它运作的正确方法?
form在tr标签内写一个可以吗?
<table>
% for my $word ( @$words_2 ) {
<tr>
<form action="/blacklist" method="post">
<td><%=$word%></td>
<td><input type="text" name="data" readonly hidden value="<%=$word%>" /></td>
<td><input class="remove" type="submit" value="Remove" /></td>
</form>
</tr>
% }
</table>
Run Code Online (Sandbox Code Playgroud) UTF-16代理区域(U + D800..U + DFFF)的位置是随机选择还是有一些逻辑上的原因,它是在这个地方?
来自perlipc /信号:
eval {
local $SIG{ALRM} = sub { die "alarm clock restart" };
alarm 10;
flock(FH, 2); # blocking write lock
alarm 0;
};
if ($@ and $@ !~ /alarm clock restart/) { die }
Run Code Online (Sandbox Code Playgroud)
如果超时的操作是system()或qx(),则此技术可能会生成僵尸.如果这对你很重要,你需要自己做fork()和exec(),并杀死错误的子进程.
我有一个类似的代码,其中超时的操作是system()或qx().
关于僵尸他们消耗记忆的坏事还是僵尸可以伤害的方式更多?
有时我必须使用裸字"STDOUT",有时裸字不起作用,有时我可以使用裸字或其他形式.是否有规则,告诉我什么时候我必须选择表格和另一个表格以及何时可以选择表格?
#!/usr/bin/env perl
use warnings;
use 5.12.0;
use utf8;
print STDOUT "Something\n"; # works
print \*STDOUT "Something\n"; # String found where operator expected
print { STDOUT } "Something\n"; # Bareword "STDOUT" not allowed while "strict subs" in use
print { \*STDOUT } "Something\n" # works
my $fh;
$fh = -t STDOUT ? STDOUT : STDERR; # Bareword "STDOUT"/"STDERR" not allowed while "strict subs" in use
$fh = -t STDOUT ? \*STDOUT : \*STDERR; # works
$fh = -t \*STDOUT ? …Run Code Online (Sandbox Code Playgroud)