I want to parse this set of lines so that if get the same pattern like **
in consecutive lines, it should print it in single with
With lookaround:
#!/usr/bin/env perl
use strict;
use warnings;
my $str = <<'EOS';
q2VDWKkY010407 2221878 Sat Mar 31 19:37 <Mailer-daemon>
(host map: lookup (my.local.domain): deferred)
<yagyavalkbhatt@yahoo.com>
<yagyavalkbhatt@yahoo.com>
q2VDWKkY010407 2221878 Sat Mar 31 19:37 <Mailer-daemon>
(host map: lookup (my.local.domain): deferred)
<yagyavalkbhatt@yahoo.com>
<yagyavalkbhatt@yahoo.com>
EOS
$str =~ s/(?<=<yagyavalkbhatt\@yahoo.com>)\s+(?=<yagyavalkbhatt\@yahoo.com>)/,/g;
print $str;
Output:
q2VDWKkY010407 2221878 Sat Mar 31 19:37 <Mailer-daemon>
(host map: lookup (my.local.domain): deferred)
<yagyavalkbhatt@yahoo.com>,<yagyavalkbhatt@yahoo.com>
q2VDWKkY010407 2221878 Sat Mar 31 19:37 <Mailer-daemon>
(host map: lookup (my.local.domain): deferred)
<yagyavalkbhatt@yahoo.com>,<yagyavalkbhatt@yahoo.com>