You appear to have forgotten to include your algorithm.
See also:
In reply to Re^2: Reaped: Re^8: partial matching of lines in perl by hippo in thread partial matching of lines in perl by Sidd@786