#!/bin/env perl
use strict;
use warnings;
sub func_array
{
my @temp = qw/a b ...
黑色阳光_cu 发表于 2010-08-05 08:58
ft~
有这么麻烦嘛,与什么上下文无关,就一点: list是 value,array 是 variable!
由于 shift 要修改传 ...
dugu072_cu 发表于 2010-08-05 14:40
but you should be aware that the ".." operator creates an array of all integers in the range. This can
take a lot of memory for large ranges. Instead use:
@results = ();
for ($i=5; $i < 500_005; $i++) {
push(@results, some_func($i));
}
This situation has been fixed in Perl5.005. Use of ".." in a "for" loop will iterate over the range, with-
out creating the entire range.
for my $i (5 .. 500_005) {
push(@results, some_func($i));
}
will not create a list of 500,000 integers.
正如我所料
sub func2 :lvalue
{
my @ar = qw/a b c/;
@ar;
}
虽然func2是返回array了,但是
...
黑色阳光_cu 发表于 2010-08-05 14:57
perldoc -q "a list and an array"
What is the difference between a list and an array?
...
dugu072_cu 发表于 2010-08-06 09:40
欢迎光临 Chinaunix (http://bbs.chinaunix.net/) | Powered by Discuz! X3.2 |