in reply to Re: How to delete a particular line in a text file after some operation on that text file at the same time
in thread How to delete a particular line in a text file after some operation on that text file at the same time

Hii, Thanks , i tried thsi but doesnt change anything in my file.
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 fr +om string # print $fho $line unless $div > 36; if( $time > 37) {return 0;} else{ return 1;} }
  • Comment on Re^2: How to delete a particular line in a text file after some operation on that text file at the same time
  • Download Code

Replies are listed 'Best First'.
Re^3: How to delete a particular line in a text file after some operation on that text file at the same time
by eyepopslikeamosquito (Archbishop) on Jan 18, 2015 at 07:35 UTC

    You need to post a small self-contained program to demonstrate your problem. That way, we can reproduce your problem, verify that the output is wrong, and then offer ways to fix it. Unfortunately, your example code above refers to $time yet that variable is not defined in your posted code.

    Oh, and make sure that all self-contained code samples you post start with:

    use strict; use warnings;

    Update: See also SSCCE (Short, Self Contained, Correct (Compilable) Example).

Re^3: How to delete a particular line in a text file after some operation on that text file at the same time
by GotToBTru (Prior) on Jan 19, 2015 at 19:44 UTC

    I assume then that Fun() never returns 0.

    sub Fun { $a = shift; return $a > 0 ? 1 : 0 } @a = (1,2,-3,4,-5,99); printf "%d, ",$_ for grep {Fun($_)} @a;

    Output:

    1, 2, 4, 99

    Updated to add simple example

    Dum Spiro Spero