in reply to Delete line

$line = '' if index( $line, 'IT' ) >= 0;

Replies are listed 'Best First'.
Re^2: Delete line
by Anonymous Monk on Aug 14, 2009 at 05:57 UTC
    #!/usr/bin/perl while(<DATA>){ @contents = grep { !/IT/ } $_; print @contents; } __DATA__ Economic slow down in IT HI
    I have tried this. But I dont want to store and print an array. While reading the lines, if it contains the word "IT" I have to delete the line
      When you say the word "IT" do you really mean "IT" as a word? It is important:
      use strict; use warnings; while(<DATA>) { print if /IT/ } __DATA__ This is IT for now Nothing of interest here Looping is used for ITeration
      gives:
      This is IT for now Looping is used for ITeration
      However if we use the word boundary anchor \b:
      while(<DATA>) { print if /\bIT\b/ }
      we only get
      This is IT for now