|
replace space with delimiter in whole file -perl
Hi
I have a file which have say about 100,000 records..
the records in it look like
Some kind of text 1234567891 abcd February 14, 2008 03:58:54 AM lmnop
This is how it looks.. if u notice there is a 2byte space between each column.. and im planning to replace that with '|' ..
say ..
Some kind of text|1234567891|abcd|February 14, 2008 03:58:54 AM|lmnop
.. here is the code which i have written.. but someone should help me in completing it... thanks in advance
open(fh_tmp,"<","$chk_file");
while (my $line = <fh_tmp>)
{
$line =~ s/ /|/g ;
open(out,">>",tmpfile);
print out $line;
close(out);
}
close(fh_tmp);
please correct me if im wrong.. thanks
|