http://qs1969.pair.com?node_id=755733

apachi15 has asked for the wisdom of the Perl Monks concerning the following question:

Hi to all Monks out there,

I think I have a siimple question for advanced perlmonks.

I have a text file which has to be importet to database. Unfortunately the fields are separeted with space characters and not Tabs. That's my code I am trying:
open(FH,"<test1.txt") or die "Can not find the file test.txt"; open(OUT,">test2.txt"); my @input=<FH>; close FH; foreach my $line(@input) { $line =~ s/ s{2,}/\t/s ; } print OUT @input; close(OUT);

I do have problems with the last\s since I need my \n

Thanks for every little help, Martin