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.#!/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); } } }
%seen = (); @uniq = (); foreach $item (@proc_name1) { unless ($seen{$item}) { $seen{$item} = 1; push (@uniq, $item); }
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |