First of all: Use
perlfunc:chomp on your input to get rid
of the trailing newline. On the other hand, that shouldn't
be the problem you currently have.
It seems to me that you might have the space in the file you
read, with a quick lookthrough I don't see the problem in
the code (or, I might just be distracted ;). I personally
would use the following for asigning the txt1 and txt2:
my $textr1 = $ref->{'txt1'};
my $textr2 = $ref->{'txt2'};
No need to put the whole ref in quotes, and I think it's cleaner if you
put the key in quotes.
--
Alfie