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:
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
why did $last_recevied get merged to @lines?
how do i split them in the outer func?