in reply to Re^3: Match Line And Combine Into One Line
in thread Match Line And Combine Into One Line
Hi Corion, well first I found a few mistakes I made, but my lines are wrapping and not breaking into new lines for each account. Corrected code below but not working as expected.
use strict; use warnings; my %reformat; my $re = qr{^(H\d+,\d+,)(.*)$}; open (NEW, ">", "Notes_Test_OUTPUT.txt" ) or die "could not open:$ +!"; open (FILE, "<", "Notes_Test.txt") or die "could not open:$!"; while (<FILE>) { chomp; /$re/; push @{ $reformat{$1} }, $2; print NEW $_, join ' ', @{ $reformat{$_} } for keys %reformat; } close (FILE); close (NEW);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Match Line And Combine Into One Line
by Corion (Patriarch) on Jul 21, 2016 at 19:04 UTC |