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";
출력 :펄 서브 루틴 반환 배열 및 STR하지만 그들은 합병지고
sending back hi1 hi2, {hi3
got lines: hi1 hi2 {hi3
got last_recevied,
예상 된 :
는sending back hi1 hi2, {hi3
got lines: hi1 hi2
got last_recevied, {hi3
이유 $last_recevied
은 @lines
에이 머지 않았다?
외부 func에서 어떻게 분리합니까?