in reply to need help to fix "use of uninitialized value..."
Quick fix:
my $Person1 = defined($1) ? $1 : ''; my $Person2 = defined($2) ? $2 : '';
But that's just covering the problem, assuming your data always has two persons in each 'Pairing Start' line. A better solution would be to re-write the regex in line 17: It's very greedy, and is probably grabbing more than you intend in several places.
First off, drop the last '.*'. You aren't saving it, and you haven't anchored the regex on that end, so it's not doing anything except eat processor cycles. (Besides, anything it could have matched is already caught in the last capture.) Next, define exactly what is allowed in a 'Person', and refine your two captures to just capture that.
What I suspect is happening is that some of your lines have whitespace at the end. This will then mean that the whole line ends up in $Person1, and $Person2 is empty. (Because the whitespace requirement is the only thing stopping the first capture from capturing the whole rest of the line.) I'm guessing putting (\w+) as your captures will likely do what you want, and solve your problem.
|
---|