in reply to Re: Delete line
in thread Delete line

#!/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

Replies are listed 'Best First'.
Re^3: Delete line
by cdarke (Prior) on Aug 14, 2009 at 09:13 UTC
    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
Re^3: Delete line
by Anonymous Monk on Aug 14, 2009 at 06:35 UTC