perl, <Correct Input, grep
<p>Please don't comment to say I already asked this, It's a logic question, I know it's mostly similar code but there are underlying syntax problems that I cannot decipher and have spent hours debugging this with no hope and I just really need this answered. And that other account was deleted so I did post this half an hour ago but can't view it. Please only comment if you want to help.</p>

<p>It should work everything is in data and it should be turning up results, i've had it working before so it must just be so syntax thing I'm not noticing. I can't get this work. I'm almost certain it's the grep statement.</p>

<pre><code>#!/usr/bin/perl
use warnings;
use strict;
open ("data", "&lt;text.txt") or die "Can't open";        #
        my @data = &lt;data&gt;;              #file looking into
        close "data";           #
while(&lt;&gt;){
        chomp;
        my $temp = $_;
        my ($name, $number, $expression) = split("\t", $temp);
        my $pattern = "\t";
        my @found = grep ( /(^$name$pattern\|$pattern$number$)/, @data );
        if(defined($found[0])){
                print $_;
                my ($what, $start, $stop, $chr, $who) = split("\t", $found[0]);
                print "\t", $chr, $start, $stop;
                @found = ();
        }
}
print "\n";
</code></pre>

<p>Input is of the format</p>

<pre><code>A1B 1   68

A1C 299 0

A2B 547 0

A2L 877 30

A2M 2   7944
</code></pre>

<p>And this is the format of the data file</p>

<pre><code>CLDN8   30214006    30216073    21  68

A1C  20808776    20811809    Y   

UBE2Q2P5Y   25431156    25437315    Y   

OR5M9   56462469    56463401    11  390162
</code></pre>

<p>I want to search for the instances of items in the first or second column of the input file in the data file which should match up with the first and 5th column(which may not exist) respectively</p>

<p>Expected output should be for this example</p>

<pre><code>A1B 1   68 21 30214006    30216073
A1C 299 0 Y 20808776    20811809
</code></pre>

<p>But I'm getting nothing</p>