in reply to Extraction n Airthmatic operation Fun on TEXTFILE

You don't need to be a Guru to do such kind of work!

I propose the following approach

To process the number or unique TIDs, remember the wise words of brother brian_d_foy in perlfaq4:
Use a hash. When you think the words "unique" or "duplicated", think "hash keys".
So extract the TID from your line (again using a regex), add them to a hash, and process the hash as you wish once you finished reading the file.

HTH, Rata

Replies are listed 'Best First'.
Re^2: Extraction n Airthmatic operation Fun on TEXTFILE
by arivu198314 (Sexton) on Jan 28, 2011 at 10:20 UTC

    See the below code,

    open(INP, "Test.txt") || die "can't open input file"; my %occuranceCounter; my %tidOccurance; while (<INP>) { if (/\-\-(TID\d+-\d+\@[\d\.]+ \d+)\-\-([^\n]+)\n/) { $tidOccurance{$1}=1; $occuranceCounter{$2}=$occuranceCounter{$2}+1; } } #print outputs foreach my $occurance (keys %occuranceCounter) { print "$occurance: ".$occuranceCounter{$occurance}."\n"; } print "Tid unique occurances is ".scalar(keys(%tidOccurance));