#!/usr/bin/perl -w use strict; $procfile2="data.txt"; open(PROC1,"$procfile2") or die "Can't open file $procfile2"; my @lines=<PROC1>; close (PROC1); my $nlines1=@lines; my @proc_name1=(); for (my $i=0;$i<$nlines1;$i++) { if($lines[$i] =~ /(.*?)\s+(\S+)/) { $pp=$1; $pp1=$2; $length_pp = length($pp); $length_pp1 = length($pp1); if ($length_pp==15 || $lengt_pp1==10) { push(@proc_name1,$pp); } if ($length_pp==10 || $length_pp1==15) { push(@proc_name1,$pp1); } } }
Now as per your suggestion we have locatedlines having 15 charcaters. How do i look only the unique values as there may be same 15 character value repeated number of times.How do i pick up unique value of them. ? I found one such code in the web. Correct me if am wrong in my understanding of the code. Now to my understanding it empties a already existing hash seen and array uniq.we check the existence using unless.let me know how can i understand the sode below.
%seen = (); @uniq = (); foreach $item (@proc_name1) { unless ($seen{$item}) { $seen{$item} = 1; push (@uniq, $item); }
[download]

UpdateThanks alot. it has now cleared my problem....

20080213 Janitored by Corion: Restored original content as per Writeup Formatting Tips


In reply to Unique number by Abhisek

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.