in reply to Re: reading file
in thread reading file

i tried by match the string "saravanan" like while(<FILE>) if($_ =~/saravanan/mg){ count++; } but can't match sa\nravanan and sara\nvanan

Replies are listed 'Best First'.
Re^3: reading file
by moritz (Cardinal) on Aug 04, 2009 at 07:10 UTC
    The reason for that is two-fold.

    First the regex sees only one line at a time, so it sees for example ravanan but not the sa\n before it. So you have to change the way you read the file and apply the regex

    The second problem is that even if the regex sees the whole file as a single string, /saravanan/ does not match "sa\nravanan", because it doesn't allow a line break in there. So you have to do something to your regex to allow that. Again I'd like to point you to perlretut for that.

    A reply falls below the community's threshold of quality. You may see it by logging in.