in reply to Re^2: 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

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
  • Comment on Re^3: How to delete a particular line in a text file after some operation on that text file at the same time
  • Select or Download Code