2011年10月18日 星期二

TOPIC : How to push reference to Array

# TOPIC : How to push reference to Array
#use strict;
$myStr = "Hello,stayhigh.Do you want to be the best hacker?";
$myStr2=" Nice to meet you!";
#@test = split(" ",$myStr);
#print "testing :",@test,"\n";


push @$result ,[split(" ",$myStr)];
push @$result ,[split(" ",$myStr2)];
print "here:",@$result,"\n";
for (@$result){
    #$refToEle = $_;
    print "\$refToEle  result:",$_,"\n";#$refToEle,"\n";
    print "\@\$refToEle result:",@$_ ,"\n"#@$refToEle,"\n";
    
}

#輸出結果
here:ARRAY(0x104a1878)ARRAY(0x104a1818)
$refToEle  result:ARRAY(0x104a1878)
@$refToEle result:Hello,stayhigh.Doyouwanttobethebesthacker?
$refToEle  result:ARRAY(0x104a1818)
@$refToEle result:Nicetomeetyou!

沒有留言:

張貼留言