in reply to format output from a exe within a perl script
Is there any reason that you can't use the Net::Ping module?
Perhaps you want something like this:
open my $PIPE, '-|', 'C:\t4ecltbundle\T4ePortPing', 'localhost', '3232 +' or die "Cannot open pipe from T4ePortPing $!"; my %data; while ( <$PIPE> ) { $data{ host } = $1 if /^Host:\s+(.+)/; $data{ conntime } = $1 if /^Connection time:\s+(.+)/; $data{ connhost } = $1 if /^Connected host:\s+(.+)/; $data{ connport } = $1 if /^Connected port:\s+(.+)/; $data{ errcode } = $1 if /^Error code:\s+(.+)/; $data{ errtext } = $1 if /^Error text:\s+(.+)/; } close $PIPE or warn $! ? "Error closing T4ePortPing pipe: $!" : "Exit status $? from T4ePortPing"; print join ',', @data{ 'host', 'conntime' }; exit 0;
|
|---|