Hi Experts,

Below is my code, unix command executes on zip file and displays the count of field 3, based on the value in field 3, i have 10 records in zip file, the field 3 contains word CHECK and KCEHC, the command which is used counts the number of CHECK and KCEHC

my $result1 = `gunzip -c $file|cut -f3 -d'|'|sort|uniq -c`;

The input zip file contains, the 11 records

ABC|123|CHECK|1| DEF|456|CHECK|1| GHI|789|CHECK|1| JKL|101|CHECK|1| ABC|123|CHECK|1| DEF|456|CHECK|1| GHI|789|CHECK|1| JKL|101|KCEHC|1| ABC|123|KCEHC|1| DEF|456|KCEHC|1| GHI|789|KCEHC|1|

gives me this error message / faulty output:

2 4 CHECK 6 KCEHC

I need to store the values 4 in $c and 6 in $c2, could you please suggest how can we do that

I also tired the below one....

my $r = `gunzip -c $file|cut -f3 -d'|'|sort|uniq -c`; my $c1 = substr( $r, 16,-2); my $c2 = substr( $, 9,-9);

This gives me the output as...

<code> $c1 = 4 $c1 = 6 <code>

I have a question to experts, was this correct method


In reply to Re^3: How to fetch the value of unix command result by rajsai28
in thread How to fetch the value of unix command result by rajsai28

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.