in reply to Extract a small part of a long sentence using regular expressions
Eclectic TIMTOWTDI:
use Data::Dump; use strict; use warnings; my $line = qq([AHB_REPORTER][INFO]: action(62,1,0,0,0,0,5,53,9,0,190)D:/XYZ/reg/T +ests/Mcu/A_test.cCALL: (null)); my $key = q(a); my %hash = map { $key++ => $_ } grep { $_ != 0 } &{ sub { $line =~ /action\(([^)]+)\)/; split /,/, $1; } }; dd \%hash; __END__ { a => 62, b => 1, c => 5, d => 53, e => 9, f => 190 }
Regards, Karl
«The Crux of the Biscuit is the Apostrophe»
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Extract a small part of a long sentence using regular expressions
by Anonymous Monk on Dec 02, 2014 at 15:53 UTC | |
by choroba (Cardinal) on Dec 02, 2014 at 16:02 UTC | |
by karlgoethebier (Abbot) on Dec 02, 2014 at 17:19 UTC | |
by choroba (Cardinal) on Dec 02, 2014 at 17:44 UTC | |
by karlgoethebier (Abbot) on Dec 02, 2014 at 20:31 UTC | |
by Anonymous Monk on Dec 02, 2014 at 16:07 UTC | |
by karlgoethebier (Abbot) on Dec 02, 2014 at 17:28 UTC |