m/(?<word>\w*a$)/
Run Code Online (Sandbox Code Playgroud)
我收到这个错误:
Sequence (?<w...) not recognized in regex;
Run Code Online (Sandbox Code Playgroud) $text =~ s/(cat|tomatoes)/ ${{ qw<tomatoes cat cat tomatoes> }}{$1} /ge;
Run Code Online (Sandbox Code Playgroud)
我不能代替${{ qw<tomatoes cat cat tomatoes> }}{$1}用{ qw<tomatoes cat cat tomatoes> }->{$1},为什么呢?
UPDATE
5 @array = qw<a b c d>;
6 $ref = \@array;
7 @{$ref} = qw<1 2 3 4>;
8 #@$ref = qw<1 2 3 4>;//also works
9 print "@array";
Run Code Online (Sandbox Code Playgroud)
因此它既不表示{}也不${}需要解除引用,{}只有在出现歧义时才需要,并且$只在标量上下文中才需要.
11 package C;
12 $_ = 5;
13 print "$_\n$C::_\n$::_\n";
Run Code Online (Sandbox Code Playgroud)
输出:
5
5
Run Code Online (Sandbox Code Playgroud)
我们知道$_Perl中的一个超全局变量,但为什么第一次赋值给这个变量会导致同时赋值$::_?
UPDATE
package C;
$_ = 5;
print "$_\n$C::_\n$::_\n";
package main;
print "####in main::\n";
$_ = 2;
print "$_\n$::_\n";
package A;
our $_ = 1;
$_ = 4;
print "####in A::\n";
print "$_\n$::_\n$A::_\n";
print "####in B::\n";
package B;
$_ = 3;
print "| $_ | \n
|$::_ | \n
|$B::_\n";
Run Code Online (Sandbox Code Playgroud)
在最后print,你可以看到,$_并且$::_是不同的.
| 3 |
|2 …Run Code Online (Sandbox Code Playgroud) x|m expr Evals expr in list context, dumps the result or lists methods.
p expr Print expression (uses script's current package).
Run Code Online (Sandbox Code Playgroud)
它们看起来和我一模一样,有什么不同?
另外,在shell环境中是否有像上/下箭头键那样的捷径?
最后,如果我想转储数组,只需:
int array[dim1][dim2]..;
A(array, dim1, dim2, dim3, dim4...);
Run Code Online (Sandbox Code Playgroud)
在C中有可能吗?
UPDATE
如何定义arrayin 的类型,A(array, dim1, dim2, dim3, dim4...);以便编译器不会发出任何警告?
print "\e[4m", $prompt, "\e[24m", "\e[1m";
Run Code Online (Sandbox Code Playgroud)
它似乎在bash中不起作用:
[root@dev-test ~]$ echo "\e[4mhello world\e[24m\e[1m"
\e[4mhello world\e[24m\e[1m
Run Code Online (Sandbox Code Playgroud) 如何写FORMAT_OF(type),所以,这将是%d对int,%s对char *,等等.
是否有宏来获取基本数据类型的格式?
for(i = 0; i < 5; i++){
int j;
printf("%X\n", &j);
}
Run Code Online (Sandbox Code Playgroud)
j在此循环中创建了多少个临时变量?
是j创建5次,还是只创建一次?
虽然地址相同..