我用这种方式创建了一个多维数组:
#!/usr/bin/perl
use warnings;
use strict;
my @a1 = (1,2);
my @a2 = (@a1,3);
Run Code Online (Sandbox Code Playgroud)
但事实证明我仍然有一个一维数组......
perl中的正确方法是什么?
$ref = \%hash;
$ref = \@hash;
Run Code Online (Sandbox Code Playgroud)
我如何使用perl中的typeglob做与引用相同的操作?
perl需要解释的具体步骤是$$ref{key}什么?
以下全部来自man epoll页面:
函数do_use_fd()使用新的就绪文件描述符,直到EAGAIN由read(2)或write(2)返回。
ET触发的代码示例:
for(;;) {
nfds = epoll_wait(kdpfd, events, maxevents, -1);
for(n = 0; n < nfds; ++n) {
if(events[n].data.fd == listener) {
client = accept(listener, (struct sockaddr *) &local,
&addrlen);
if(client < 0){
perror("accept");
continue;
}
setnonblocking(client);
ev.events = EPOLLIN | EPOLLET;
ev.events = EPOLLIN | EPOLLET;
ev.data.fd = client;
if (epoll_ctl(kdpfd, EPOLL_CTL_ADD, client, &ev) < 0) {
fprintf(stderr, "epoll set insertion error: fd=%d\n",
client);
return -1;
}
}
else
do_use_fd(events[n].data.fd);
}
}
Run Code Online (Sandbox Code Playgroud)
因此,对于read/write …
#include <unistd.h>
int main(int argc, char* argv[])
{
char buf[500];
read(0, buf, 5);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
以上read5个字符stdin,但如果我输入超过5:
12345morethan5
[root@ test]# morethan5
-bash: morethan5: command not found
Run Code Online (Sandbox Code Playgroud)
其余字符将作为shell命令执行.
这种行为是由标准定义的吗?
int main(int argc,char* argv[]);
Run Code Online (Sandbox Code Playgroud)
如果有一个'\0'字符A,它会被分成两个参数吗?
./programe "A"
Run Code Online (Sandbox Code Playgroud)
我不能轻易地重现它,因为我不能把它'\0'放入A中,但可能有人可以.
[root@ test]# perl -e 'use re "debug";"a" =~ /.*/';
Compiling REx `.*'
size 3 Got 28 bytes for offset annotations.
first at 2
1: STAR(3)
2: REG_ANY(0)
3: END(0)
anchored(MBOL) implicit minlen 0
Offsets: [3]
2[1] 1[1] 3[0]
Matching REx ".*" against "a"
Setting an EVAL scope, savestack=3
0 <> <a> | 1: STAR
REG_ANY can match 1 times out of 2147483647...
Setting an EVAL scope, savestack=3
1 <a> <> | 3: END
Match successful!
Freeing REx: `".*"'`
Run Code Online (Sandbox Code Playgroud)
任何人都能解读这个?
& # disown the functions
Run Code Online (Sandbox Code Playgroud)
我们都知道&把任务放到后台,最重要的是让任务失败.
但它是如何实现的?
int open(const char *path, int oflag, ... );
Run Code Online (Sandbox Code Playgroud)
问题是它的论点不固定,
有没有办法包裹它?
int my_open(const char *path, int oflag, ... ){
}
Run Code Online (Sandbox Code Playgroud)