in reply to Re^8: Join multiple lines in a string based on regex.
in thread Join multiple lines in a string based on regex.
use strict; use warnings; my $row =""; my $inarray=0; while (<DATA>) { chomp; s/^\s+//; # <-- New line added <---- if (/^array|^unassigned/){ print "$row\n" if $inarray; $row=$_; $inarray=m/^array/; next; } next unless $inarray; $row .= " $_"; } print "$row\n" if $inarray; __DATA__
"You're only given one little spark of madness. You mustn't lose it." - Robin Williams
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^10: Join multiple lines in a string based on regex.
by pr33 (Scribe) on Dec 22, 2014 at 20:16 UTC | |
by NetWallah (Canon) on Dec 24, 2014 at 00:54 UTC | |
by pr33 (Scribe) on Dec 24, 2014 at 01:46 UTC | |
by Anonymous Monk on Dec 24, 2014 at 02:42 UTC | |
by pr33 (Scribe) on Dec 24, 2014 at 04:46 UTC | |
|