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


in reply to using regex with records

Instead of reading in a record at a time, this solution reads the file line by line. 'ACCOUNT-dddddd' precedes the closed date and the created date follows the closed date. So, if this data is uniform as presented, you could enter the two dates into the %data hash for the current account number.
#!/usr/bin/perl use strict; use warnings; my (%data, $acct, $close_date, $create_date); while (<DATA>) { next if /^Remedy Account data:/ .. /^Remedy Case data:/; if (/^ACCOUNT-(\d+)/) { $acct = $1; } elsif (/^ClosedDate = ([-\d :]+)/) { $close_date = $1; } elsif (/^CreatedDate = ([-\d :]+)/) { $create_date = $1; $data{ $acct } = { closed => $close_date, created => $create_d +ate}; } } use Data::Dumper; print Dumper \%data;

This prints

$VAR1 = { '09782' => { 'created' => '2007-10-23 21:10:10', 'closed' => '2007-10-26 16:31:53' } };
Hope this helps :-)