in reply to reading file

What have you tried so far, where did you get stuck?

I suggest reading perlintro and perlretut, these documents should contain enough information and examples to get you started.

Replies are listed 'Best First'.
Re^2: reading file
by saranperl (Initiate) on Aug 04, 2009 at 07:03 UTC
    i tried by match the string "saravanan" like while(<FILE>) if($_ =~/saravanan/mg){ count++; } but can't match sa\nravanan and sara\nvanan
      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.