in reply to Extract a small part of a long sentence using regular expressions
use warnings; use strict; use Data::Dumper; my @actionData; while (my $line = <DATA>) { if ( $line =~ /action\(([^)]+)\)/ ) { my @nums = grep { $_ != 0 } split /,/, $1; push @actionData, @nums; } } print Dumper(\@actionData); __DATA__ [AHB_REPORTER][INFO]: action(62,1,0,0,0,0,5,53,9,0,190)D:/XYZ/reg/Test +s/Mcu/A_test.cCALL: (null)
outputs:
$VAR1 = [ 62, 1, 5, 53, 9, 190 ];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Extract a small part of a long sentence using regular expressions
by swatzz (Novice) on Dec 02, 2014 at 13:34 UTC | |
|
Re^2: Extract a small part of a long sentence using regular expressions
by swatzz (Novice) on Dec 02, 2014 at 13:32 UTC |