in reply to change a line or string in file

sachin cat,

You try this,

open (FIN, "test.txt")|| die ("test.txt does not exists"); undef $/; $instr = <FIN>; $instr =~ s|/prj/sw/tool|/prj/vlsi/toolsmodule|si; print "$instr";

Prasad

Replies are listed 'Best First'.
Re^2: change a line or string in file
by sachin_chat (Initiate) on Jan 19, 2005 at 10:04 UTC
    hi prasad is your solution takes in to consideration that there are many other lines , other than what i want to replace. Thanks sachinc
      sachin chat,

      $/ is a input record separator, when you read a content in the file, it will undef the newline characters("\n") in the file if we use undef $/;. (default value of input record separator is "\n")

      $instr will take all the contents in the file (not first line alone).

      is your solution takes in to consideration that there are many other lines

      yes, if there is also only one line, you will get the correct output.

      Prasad

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