文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>两个程序的不同之处

两个程序的不同之处

时间:2006-10-20  来源:yszll

第一个程序:
#! /usr/local/bin/perl -W
#fig06_07.pl
@array=scalarOrList();
$"="->";  # set default separator character
print "Return: \n@array\n";
print $";
print "\nReturned: " . scalarOrList(), "\n";

sub scalarOrList {
   if(wantarray()) {
      return 'this','is','a','list','of','strings';
   }
   else {
      return 'hello';
   }
}

输出如下:
Return:
this->is->a->list->of->strings
->
Returned: hello

第2个程序:
#! /usr/local/bin/perl -W
#fig06_07.pl
@array=scalarOrList();
$"="->";  # set default separator character
print "Return: \n@array\n";
print $";
print "\nReturned: " ,scalarOrList(), "\n";

sub scalarOrList {
   if(wantarray()) {
      return 'this','is','a','list','of','strings';
   }
   else {
      return 'hello';
   }
}
输出如下:
Return:
this->is->a->list->of->strings
->
Returned: thisisalistofstrings

差别仅在于一个是 "." 一个是","
相关阅读 更多 +
排行榜 更多 +
单挑幸存者安卓版

单挑幸存者安卓版

飞行射击 下载
决战战地指挥官

决战战地指挥官

飞行射击 下载
鸡仔幸存者最新版

鸡仔幸存者最新版

飞行射击 下载