in reply to Re^2: Skip lines until you find a delimiter >>
in thread Skip lines until you find a delimiter >>
As an update note: If for some reason this doesn't do exactly what you want, I expect you to spend some time studying the code and for you to make a serious attempt at modifications. I think you are doomed if you just copy code without understanding how it works.
#!/usr/bin/perl use strict; use warnings; use List::Util qw(sum); while (<DATA>) { my ($var) = /:\>\>(\w+)/; # could have been done my (@nums) = /,\s*(\d+)/g; # on one line... next unless $var; # skips bogus lines print "$var,",sum(@nums),"\n"; } #prints: #test,10 #test1,26 __DATA__ <"Session Date:Mar 13/2017 ":>>test", 1,2,3,4 ":>>test1", 5,6,7,8 end>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Skip lines until you find a delimiter >>
by RohanGuddad (Initiate) on Mar 15, 2018 at 13:56 UTC | |
by marto (Cardinal) on Mar 15, 2018 at 14:17 UTC | |
by karlgoethebier (Abbot) on Mar 15, 2018 at 16:45 UTC | |
by Marshall (Canon) on Mar 15, 2018 at 18:30 UTC |