in reply to Re: Change a line in a file
in thread Change a line in a file

Thank you CountZero. This gave me the best solution. Turns out I was trying to open the file incorrectly as "netbpa" astutely noticed but in the end I did not have to open the file the second time. I took your shortest suggestion and used it on the string $trace as follows:
sub t_write { my($file, $aOrder) = @_; my($trace) = $aOrder->{trace_file_data}; if (!defined($trace) || length($trace) == 0) { print "No trace file.\n"; return; } $trace =~ s/JOB=.*/RMT=$file/; open(F, "> $file\0") or die "Can't create trace-file $file ($!)\n" +; print F $trace; close(F); #make a comment that this was done print "Trace file: $file\n"; }
This solution added only one line to the original subroutine! Thank you. Warm regards,