in reply to Splitting Data
And the output is as expected -use Data::Dumper; my $str="OP=SiDarkRefRead&DEV=SI_PHOTO_DEV&CMD=READ&STATUS=PASS&READ_D +ATA={ 3 15 0 255 50000 1000 [0] = 1 [1] = 2 [2] = 3 [3] = 4 [4] = 5 [ +5] = 6 [6] = 7 [7] = 8 [8] = 9 [9] = 10 [10] = 1 [11] = 2 [12] = 3 [1 +3] = 4 [14] = 5 [15] = 6 [16] = 7 [17] = 8 [18] = 9 [19] = 10"; my @p = map { $_ =~ /\[/ ? $_ : () } split /(\[\s*\d+\s*\]\s*=\s*\d+)/ +, $str; # ^ only want [dd]=dd ^ split & capture print Dumper(\@p);
$VAR1 = [ '[0] = 1', '[1] = 2', '[2] = 3', '[3] = 4', '[4] = 5', '[5] = 6', '[6] = 7', '[7] = 8', '[8] = 9', '[9] = 10', '[10] = 1', '[11] = 2', '[12] = 3', '[13] = 4', '[14] = 5', '[15] = 6', '[16] = 7', '[17] = 8', '[18] = 9', '[19] = 10' ];
|
|---|