G'day OrdinaryFIlmmaker,
Welcome to the Monastery.
It would've helped if you'd read "How do I post a question effectively?" before posting. Providing your data as paragraph (<p>) text does not allow us to see what it really is: HTML will, amongst other things, convert sequences of whitespace to a single space. We might have got clues from your code, but you didn't post that.
Here's what your input data looked like (newlines are represented by '$'s):
$ cat -vet pm_11118005_data Eli Stern,,, $ 10-Nov-19,,, $ 1 subscriber,,, $ ,,, $ Abdessamed Ham,,, $ 15-Nov-19,,, $ 0 subscribers,,, $ ,,, $ Arne Martinson,,, $ 22-Nov-19,,, $ 0 subscribers,,, $ ,,, $
Your wanted output is also questionable: space before 1st date but not the others; and, records ending with 2 commas, a space, and a newline.
Except for the dodgy space before the 1st date, this code produces the output you asked for:
#!/usr/bin/env perl use strict; use warnings; use autodie; { open my $fh, '<', 'pm_11118005_data'; local $/ = "\n,,, \n"; while (<$fh>) { chomp; print join(',', $., split(/,,, \n?/)), ",, \n"; } }
Output:
1,Eli Stern,10-Nov-19,1 subscriber,, 2,Abdessamed Ham,15-Nov-19,0 subscribers,, 3,Arne Martinson,22-Nov-19,0 subscribers,,
Update:
A very minor update (adding a single missed letter) which changes the meaning (to what I originally intended).
Was: "I would've helped if ..."
Now: "It would've helped if ..."
— Ken
In reply to Re: 20 years confused
by kcott
in thread 20 years confused
by OrdinaryFIlmmaker
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |