I have a file:
XXGuy:Tom1XXBill1XXXXBlah2XX\n
XXFriend:Bob1XXcarry:Stuff1XX\n
XXGuy:Tom2XXBill2XXXXBlah7XX\n
XXFriend:Bob2XXcarry:Stuff2XX\n
The content I want to extract is Tom{1,2}, Bob1{1,2}, and Stuff1{1,2} and print:
"Tomx's friend is Bobx and is carrying Stuffx"
I can use a multi-line regex with multiple capture groups and Tomx, Bobx, and Stuffx will be in $1, $2, and $3 and I can print each element out but can't really process them in the way I'd like as described - I don't know how to store into what structure (Array/Hash don't see to fit the bill here?) and retrieve the data.
I'm looking at these posts:
Perl: Pulling pairs of values from an array
Finding multiple matches with multiline regex perl
Suggestions?
No comments:
Post a Comment