专注各种脚本编程
Baidu
加入收藏夹
本站内容有下面分类知识,欢迎您的到来^_^
shell相关:指令篇 基础篇 脚本欣赏 编程实例 shell问问 shell视频教程 技巧篇 水平测试 E文资料 vi编辑器 高级Bash脚本编程指南
其他:mysql perl c语言 oracle
当前位置:| 主页>perl>

perl进程启动函数eval/system/fork

百度收藏 QQ搜藏
函数名 eval
调用语法 eval(string)
解说 将string看作Perl语句执行。
正确执行后,系统变量$@为空串,如果有错误,$@中为错误信息。
例子 $print = "print (\"hello,world\\n\");";
eval ($print);
结果输出 hello, world

函数名 system
调用语法 system(list)
解说 list中第一个元素为程序名,其余为参数。
system启动一个进程运行程序并等待其结束,程序结束后错误代码左移八位成为返回值。
例子 @proglist = ("echo", "hello,world!");
system(@proglist);
结果输出 hello, world!

函数名 fork
调用语法 procid = fork();
解说 创建程序的两个拷贝--父进程和子进程--同时运行。子进程返回零,父进程返回非零值,此值为子程序的进程ID号。
例子 $retval = fork();
if ($retval == 0) {
  # this is the child process
  exit; # this terminates the child process
} else {
  # this is the parent process
}
结果输出
上一篇:perl读写股票文件程序 下一篇:perl进程启动函数pipe/exec/syscall

power by soyo123 2007-2008