I'm having a trouble formatting a file into a pipe delimited set of records.
The record file (file.txt) looks like this:
0211121253 Mike Dell ID06533 0211121253 Chris Jones ID02014 0211121253 Pa Kettle ID65255 0111119112 Mitch Poo ID05983
I'm trying to read the file in to a handle and put a pipe ("|") at the beginning of each line. Then replace the spaces in each line with a pipe and then add a pipe to the. So, I would end up with a text file end of each line. It should resemble the following:
|0211121253|Mike|Dell|ID06533| |0211121253|Chris|Jones|ID02014| |0211121253|Pa|Kettle|ID65255| |0111119112|Mitch|Poo|ID05983|
Here's part of my code. I'm using the DBI module to query the original data from Oracle. I believe my error is because I'm working with an array and not string vars.
I would appriciate some advice on how this could be done.
Thanks, Neurotoxx$sth->execute; open (OUTFILE, "> file.txt") or die "Cant open dat file : $!"; while (@row = $sth->fetchrow_array) { $_ =~ s/\s/\|/g; print OUTFILE "@row\n"; } close OUTFILE;
In reply to parse array to replace specific spaces with pipes by neurotoxx
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |