, .
, , . , ++$#array " ", . ( , - , .) , , , : $#array (); . , . :
my @array = qw/1 2 3/;
++$#array;
$array[$#array] = qw/4/;
print "@array\n"
And even, for added pleasure, these are:
my @array = qw/1 2 3/;
$#array += 5;
foreach my $wtf (@array) {
if (defined $wtf) {
print "$wtf\n";
}
else {
print "undef\n";
}
}
And, yes, Cookbook Perl is happy to mess with $#arrayto grow or truncate arrays (chapter 4, recipe 3). I still find it ugly, but maybe it's just a lingering βbut that numberβ of prejudice.
source
share