+ -
当前位置:首页 → 问答吧 → PERL 常量数组如何遍历?

PERL 常量数组如何遍历?

时间:2011-03-04

来源:互联网

use constranst RA=(1,2,3,4);
foreach my $a (RA)
这样对吗

作者: ztj2247   发布时间: 2011-03-04

明显不行了。

作者: liyangole   发布时间: 2011-03-04



QUOTE:
use constranst RA=(1,2,3,4);
foreach my $a (RA)
这样对吗
ztj2247 发表于 2011-03-04 16:17

  1. use Readonly;
  2. Readonly::Array   my @RA => (1,2,3,4);

  3. foreach (@RA){
  4.   print "$_\n";
  5. }
复制代码

作者: jason680   发布时间: 2011-03-04

回复 ztj2247


perldoc constant
  1. use constant RA => (1,2,3,4);
  2. for (RA) {
  3.     print ;       
  4. }
复制代码

作者: yybmsrs   发布时间: 2011-03-04