my $file = 'C:\shekhar_Axestrack_Intern\WindowCreation\ListOfIpAdress.txt'; tie my @lines, 'Tie::File', $file or die "can't update $file: $!"; # define sub Fun such that it returns 0 if Time > 34, 1 otherwise @lines = grep { Fun($_) } @lines; untie @lines; sub Fun { my($line) = @_; #I do manupulation on this line to get time from string # print $fho $line unless $div > 36; if( $time > 37) {return 0;} else{ return 1;} }