in reply to Re^4: Retrieving information from an executable program
in thread Retrieving information from an executable program
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my @output = `./retrieve 2301`; my ($name, $status, $cid); my $deref="LEVEL0"; my %vars = ( 'NAME' => \$name, 'CID' => \$cid, 'STATUS' => \$status, ); for my $line (@output) { $deref= "LEVEL1"; my ($key, $val) = split /:/, $line, 2; $deref="LEVEL2"; if ($vars{ $key }) { ${ $vars{ $key } } = $val; $deref= "LEVEL3"; } else { warn "Unknown key '$key', discarded"; $deref= "LEVEL5"; }; }; my $hashref = \%vars; print "\n$deref\n"; print "\n$hashref->{CID}\n"; print "\n$hashref->{NAME}\n"; print "\n$hashref->{STATUS}\n";
CID: 2301 NAME:Jane STATUS:OK LEVEL0 SCALAR(0x8870e78) SCALAR(0x8870e60) SCALAR(0x8870e30)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Retrieving information from an executable program
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 |