http://www.perlmonks.org?node_id=1048814


in reply to Parsing multi-line record with varying data

Here is an example that reads through the example file, and prints each uid along with the number of id-info lines attached to it:

use strict; use warnings; use 5.010; local $/ = "--\n"; while (<DATA>) { if (/^rn: uid:(\S+),/m) { my $uid = $1; my $count = 0; $count++ for /^id-info:/mg; say "$uid: $count"; } } __DATA__ -- rn: uid:<user>, <irrelevant-text> id-info: <URL> | <ID> | <random-string> creation-time: 1366069064 -- rn: uid:<user>, <irrelevant-text> id-info: <URL> | <ID> | <random-string> id-info: <URL> | <ID> | <random-string> id-info: <URL> | <ID> | <random-string> creation-time: 1366069064 -- rn: uid:<user>, <irrelevant-text> id-info: <URL> | <ID> | <random-string> id-info: <URL> | <ID> | <random-string> # random empty line in each entry with 'deletion-time' deletion-time: 1367949064 creation-time: 1366069064 --

I hope it can serve as a starting point for you.

If you need more help, please provide example (not whited-out) input data along with exactly what output you are expecting.