my ($name, $status, $cid);
my %vars = (
'NAME' => \$name,
'CID' => \$cid,
'STATUS' => \$status,
);
for my $line (@output) {
my ($key, $val) = split /:/, $line, 2;
if ($vars{ $key }) {
${ $vars{ $key } } = $val;
} else {
warn "Unknown key '$key', discarded";
};
};
I'm not sure whether that's worth the trouble though. |