[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] search and replace a specific line in a file.



Hi,

I am writing a CGI that searches a flat file for a line that matches a
specified string.  What I want to do when I find the line is to manipulate
some of the contents and then write the line back to the file at the same 
line number.  I am able to do everything except for the print to the file
at the right spot (it just appends to the file).  I have the Camel book
and the Llama book and I can't seem to figure out how to print to a 
specific line in the file.  I know about the "$." variable that holds the 
current input line number and that "$_" contains the input line contents,
but how do I get "print" to print $string to OUTPUTFILE at "$." ? 

I am sure this is probably a nobrainer and since I have no brain I should
be able to figure it out....but I can't.  Can anyone help?

By the way thank god for this list!

Thanks in advance,
Ernesto
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
% Ernesto Gonzalez                      %
% Computer Services Associate           %
% Massachusetts General Hospital        %       
% Dept of Molecular Biology             %
%                                       %
% Gonzalez@molbio.mgh.harvard.edu       %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"RADICALISM = The conservatism of tomorrow injected into the affairs of
              today" - Ambrose Bierce