fellow monks,
I'm working with a number of data files that have no defined delimiter. The goal is to take the data, delimit it into appropriate columns, and then insert the data into a db. I could obtain the required results via the following code, but I would like to shoot for something more succinct. Thanks in advance for any insights and suggestions for improvement. cheers!
#!/usr/bin/perl -w
use strict;
while (<DATA>) {
my $line = $_;
$line =~ s/\s+/\|/;
$line =~ s/\s+/\|/;
$line =~ s/\s+/\|/;
$line =~ s/\s+/\|/;
$line =~ s/\s+/\|/;
print $line;
}
__DATA__
This# is stand alone data "but this data needs to , sta
+y together/
and here is some more -but this is a single column
..which produces the desired output:
This#|is|stand|alone|data|"but this data needs to , stay together/
and|here|is|some|more|-but this is a single column