in reply to Re^5: substitute on file line by line not working syntax error
in thread Search and Replace line by line not working on Filehandle

OK. Seems i have to use the "Seek thing". This seems to work:

#!/usr/bin/perl use strict; use warnings; open (IN, "+<C:/oracle/ora81/network/ADMIN/SQLNET.ORA") || die "cant o +pen $!"; my @file = <IN>; seek IN,0,0; foreach my $file (@file){ $file =~ s/^SQLNET\.AUTHENTICATION_SERVICES=\ \(NTS\)$/#\ SQLNET\.AUTH +ENTICATION_SERVICES=\ \(NTS\)/i; print IN $file; } close IN;

Thanks
MH

Replies are listed 'Best First'.
Re^7: substitute on file line by line not working syntax error
by cdarke (Prior) on Jan 15, 2010 at 11:28 UTC
    I'm surprised it works - are you sure?
    seek IN,0,0; just sets the position to beginning of file. See seek.
      Yes. Honestly i must admit i found this on the web and just changed it to my needs, without understanding it completely, since it worked i didnt bother for the moment ...