#use strict;
push @{$result},"one";
print "\$result :",$result,"\n";
print "\@\$result:",@$result,"\n";
@arr =(1..10);
$ref = \@arr;
print "get array data by ref :",@$ref;
#輸出結果:
$result :ARRAY(0x10463af0)
@$result:one
get array data by ref :12345678910
If you wanted just to append to a row, you'd have to do something a bit funnier looking:
# add new columns to an existing row
push @{ $LoL[0] }, "wilma", "betty";
Notice that I couldn't say just: push $LoL[0], "wilma", "betty"; # WRONG!
In fact, that wouldn't even compile. How come? Because the argument to
push()
must be a real array, not just a reference to such.
沒有留言:
張貼留言