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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Simple or not
by toolic (Bishop) on Apr 06, 2009 at 14:46 UTC | |
Re: Simple or not
by BrowserUk (Patriarch) on Apr 06, 2009 at 16:25 UTC | |
Re: Simple or not
by almut (Canon) on Apr 06, 2009 at 14:38 UTC | |
Re: Simple or not
by kennethk (Abbot) on Apr 06, 2009 at 14:42 UTC | |
Re: Simple or not
by ELISHEVA (Prior) on Apr 06, 2009 at 15:09 UTC | |
Re: Simple or not
by apachi15 (Initiate) on Apr 07, 2009 at 07:25 UTC | |
by kennethk (Abbot) on Apr 07, 2009 at 18:24 UTC |
Back to
Seekers of Perl Wisdom