As for your final question - firstly @recordSource was slurping in all the arguments returned from the split and secondly split won't work how you expect it to (unfortunately) so consort the docs. Here's what you want (although I'm using an array of arrays of arrays as that seems to map to your data better)use strict; use Data::Dumper; $_ = "10001 LONG RECORD\n BEGIN RECORD A, CODE B, TABLE C END \n NEXT\n STANDARD DATA 1 BEGIN CODE A, RECORD B END NEXT\n SHORT RECORD BEGIN TABLE B END NEXT\n STANDARD DATA 2 BEGIN CODE C, RECORD D, FILE END;"; my(@records) = m< \bBEGIN\b \s+ (.*?) \s+ \bEND\b >gx; print Dumper(\@records); __output__ $VAR1 = [ 'RECORD A, CODE B, TABLE C', 'CODE A, RECORD B', 'TABLE B', 'CODE C, RECORD D, FILE' ];
my @subrecs; for(@records) { my @items = split ', '; push @subrecs => [ [map { (split ' ')[0] } @items], [map { (split ' ')[1] } @items], ]; } print Dumper(\@subrecs); __output__ $VAR1 = [ [ [ 'RECORD', 'CODE', 'TABLE' ], [ 'A', 'B', 'C' ] ], [ [ 'CODE', 'RECORD' ], [ 'A', 'B' ] ], [ [ 'TABLE' ], [ 'B' ] ], [ [ 'CODE', 'RECORD', 'FILE' ], [ 'C', 'D' ] ] ];
_________
broquaint
In reply to Re: Multiple RegEx Matches in a single string
by broquaint
in thread Multiple RegEx Matches in a single string
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |