in reply to Re^2: Retrieving information from an executable program
in thread Retrieving information from an executable program
No, there basically is no way to assign your variables that way. Well, you could store the names and references in a hash and then use that:
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Retrieving information from an executable program
by kitifu (Initiate) on Jul 26, 2010 at 21:18 UTC | |
|
Re^4: Retrieving information from an executable program
by kitifu (Initiate) on Jul 26, 2010 at 16:18 UTC | |
by Corion (Patriarch) on Jul 26, 2010 at 16:54 UTC | |
by kitifu (Initiate) on Jul 26, 2010 at 18:52 UTC | |
by Corion (Patriarch) on Jul 26, 2010 at 19:05 UTC | |
by kitifu (Initiate) on Jul 27, 2010 at 02:07 UTC | |
by kitifu (Initiate) on Jul 27, 2010 at 04:07 UTC |