This is just a wild guess on my part - I guess that extra new lines meant spacers between these records - but maybe not?:
I guess something very, very simple like this is possible? 3 input lines to one output line?use strict; use warnings; my $line; while (<DATA>) { chomp; if ( (/:$/../^\s*$/) =~ /^\d+$/) #exclude endpoint. { s/\s,\s/,/; $line .= " $_"; } elsif (defined $line) { $line =~ s/^\s*//; print "$line\n"; $line = undef; } } print "$line\n" if defined $line; # just to be sure # all output is done =prints 99~Arun~Kumar~Mobilenum: 1234-567,from Earth Human 98~Mahesh~Babu~Mobilenum: 5678-901,from Earth Human 98~Mahesh~Babu~Mobilenbbb: 5678-901,from Earth Human =cut __DATA__ 99~Arun~Kumar~Mobilenum: 1234-567 , from Earth Human 98~Mahesh~Babu~Mobilenum: 5678-901 , from Earth Human 98~Mahesh~Babu~Mobilenbbb: 5678-901 , from Earth Human
use strict; use warnings; my $input = do {local $/; <DATA>}; my @lines = $input =~ m/(.*\n.*\n.*\n)/g; foreach my $line (@lines) { $line =~ s/\n/ /g; $line =~ s/ , /,/g; print "$line\n"; } =Prints 99~Arun~Kumar~Mobilenum: 1234-567,from Earth Human 98~Mahesh~Babu~Mobilenum: 5678-901,from Earth Human 98~Mahesh~Babu~Mobilenbbb: 5678-901,from Earth Human =cut __DATA__ 99~Arun~Kumar~Mobilenum: 1234-567 , from Earth Human 98~Mahesh~Babu~Mobilenum: 5678-901 , from Earth Human 98~Mahesh~Babu~Mobilenbbb: 5678-901 , from Earth Human
In reply to Re: perl regex to match newline followed by number and text
by Marshall
in thread perl regex to match newline followed by number and text
by arunkumarzz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |