G'day Perlseeker_1,

As already stated by others, there's a disconnect between your title, code and output.

The following produces the output you seem to want based on the data you posted. Perhaps replacing my <DATA> with your <$handle> will achieve the result you're after.

#!/usr/bin/env perl -l use strict; use warnings; my %result; ++$result{join ' --> ' => (split /,/)[1,4]} while <DATA>; print "$_ --> $result{$_}" for sort keys %result; __DATA__ 01,AB1,CDEF,CHINA,T1, 02,AB2,CDEF,CHINA,T1, 03,AB1,CDEF,JAPAN,T2, 04,AB2,CDEF,JAPAN,T2, 05,AB3,CDEF,JAPAN,T2, 06,AB4,CDEF,JAPAN,T2, 07,AB3,CDEF,CHINA,T1, 08,AB4,CDEF,CHINA,T1, 09,AB1,CDEF,CHINA,T1, 10,AB2,CDEF,CHINA,T1, 11,AB1,CDEF,JAPAN,T2, 12,AB2,CDEF,JAPAN,T2, 13,AB3,CDEF,JAPAN,T2, 14,AB4,CDEF,JAPAN,T2, 15,AB3,CDEF,CHINA,T1, 16,AB4,CDEF,CHINA,T1,

Output:

AB1 --> T1 --> 2 AB1 --> T2 --> 2 AB2 --> T1 --> 2 AB2 --> T2 --> 2 AB3 --> T1 --> 2 AB3 --> T2 --> 2 AB4 --> T1 --> 2 AB4 --> T2 --> 2

-- Ken


In reply to Re: How to read zipped file in perl by kcott
in thread How to read zipped file in perl by Perlseeker_1

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.