#!/usr/bin/perl -w use strict; $procfile2="data.txt"; open(PROC1,"$procfile2") or die "Can't open file $procfile2"; my @lines=; 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); } } }