2
我想知道這兩者之間有什麼區別?推入Perl中的數組差異
方案1:
my @something = split(someregularexpressionhere, $somethinghere);
push(@{$hastable{$keyname}}, @something);
方案2:
my $something = split(someregularexpressionhere, $somethinghere);
push(@{$hastable{$keyname}}, $something);
另外,在標量和無效上下文中,它分裂成較老的Perls中的'@ _'數組。 – 2011-04-09 20:22:35
因此,如果我想將分詞存儲在散列表中的數組中,第一種情況會是理想的嗎?正確? – diesel 2011-04-09 20:25:38
是的。一般來說,我會避免在標量上下文中使用分割,儘管在特定情況下它是有用和可讀的。 – justarobert 2011-04-09 20:27:49