Hi,

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


In reply to Regular Expression and backquoted cmds by joec_

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.