1
sub process_feed {
my ($line) = @_;
my @lines;
my $last_received = "";
while (1) {
if ($line =~/^{(.*?)}(.*)/) {
push @lines, $1;
$line = $2;
} else {
$last_received = $line;
last;
}
}
print "sending back @lines, $last_received\n";
return (@lines, $last_received);
}
my (@lines, $leftover) = process_feed("{hi1}{hi2}{hi3");
print "got lines: @lines\n";
print "got last_recevied, $leftover\n";
OUTPUT:Perlサブルーチンの復帰配列とstrが、彼らはマージなっている
sending back hi1 hi2, {hi3
got lines: hi1 hi2 {hi3
got last_recevied,
EXPECTED:
はsending back hi1 hi2, {hi3
got lines: hi1 hi2
got last_recevied, {hi3
なぜ$last_recevied
は@lines
にマージされたのですか?
どうすれば外側のfuncで分割できますか?