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


in reply to Parsing multi-line record with varying data

Building upon BrowserUk's suggestion, perhaps the following will be helpful:

use strict; use warnings; use Data::Dumper; $/ = 'rn:'; my %hash; my $entry = 1; while (<DATA>) { chomp; /\S/ and $hash{ $entry++ } = () = /id-info:/g; } print Dumper \%hash; __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> deletion-time: 1367949064 creation-time: 1366069064 rn: uid:<user>, <irrelevant-text> creation-time: 1366069064

Output:

$VAR1 = { '4' => 0, '1' => 1, '3' => 2, '2' => 3 };