joec_ has asked for the wisdom of the Perl Monks concerning the following question:
I have the output of a backquoted command i.e.
$result=`cat $file | anotherscript.pl`;
Does a backquoted command automatically get output to stdout as well as into the string $result?
My question is this: The output looks like:
Script version 1.7
12345 hashes read from
1 database
3 read, 2 found, 2 written
ID123 ZZ00000077
ID456 ZZ00000012
ID124 NONE
What i would like to do is build up a hash of the found items i.e with IDnnn as the key and the ZZ identifier as value. I would also like a hash/array of any NONE found items again with IDnnn as key and NONE as value or if array, just IDnnn pushed onto it.
I dont particularly want the output of the command output to stdout either
I have tried a regular expression to get at the NONE lines such as :
@res = split /\n/, $result; foreach $element (@res){ if ($element=~/(.*NONE)$/m){ push @none, $element; } }
Any help would be appreciated.
Thanks
Joe
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regular Expression and backquoted cmds
by rovf (Priest) on Feb 03, 2009 at 11:44 UTC | |
by JavaFan (Canon) on Feb 03, 2009 at 11:57 UTC | |
by rovf (Priest) on Feb 03, 2009 at 12:13 UTC | |
|
Re: Regular Expression and backquoted cmds
by Bloodnok (Vicar) on Feb 03, 2009 at 12:07 UTC | |
|
Re: Regular Expression and backquoted cmds
by toolic (Bishop) on Feb 03, 2009 at 14:16 UTC |