If you had used the strictures:
use warnings; use strict;

you would have gotten these error messages:

Bareword "DUMMYHUGO" not allowed while "strict subs" in use ... Bareword "DUMMY_GENEFILE" not allowed while "strict subs" in use...

This would have lead you to suspect some kind of problem with these lines of code:

@hugo = DUMMYHUGO; @genes = DUMMY_GENEFILE;

It is not really clear what you are trying to do, but if you are trying to match names in the genes file to any name on any line of the hugo file, the following code might be a step in the right direction. Please note that this is not an attempt at a complete solution:

#!/usr/bin/env perl use warnings; use strict; my @hugos; open my $DUMMYHUGO, '<', 'DummyHugo.txt' or die "cannot open file cont +aining HUGO IDs: $!\n"; while (<$DUMMYHUGO>) { my @hugo = split; push @hugos, [@hugo]; } close $DUMMYHUGO; my $outfile = 'HUGO_dummyResults.txt'; open my $OUT, '>', $outfile or die "cannot create +the output file: $!\n"; open my $DUMMY_GENEFILE, '<', 'DummyGenes.txt' or die "cannot open fi +le containing genes: $!\n"; while (<$DUMMY_GENEFILE>) { my @genes = split; for my $href (@hugos) { my @hugo = @{$href}; for (my $i = 5; $i < 9; $i++) { if ($genes[2] eq $hugo[$i]) { print $OUT "$genes[0]\t$genes[1]\t$genes[2]\t$genes[3] +\t$hugo[1]\n"; } } } } close $DUMMY_GENEFILE; close $OUT; exit;

The output file will then contain:

ID1 Id2 Katie Path KJRJ ID1a Id2a Dave Path DJL ID1b Id2b Kean Path PKKJ ID1c Id2c Paul Path PKKJ ID1d Id2d Sandra Path SKJ

This code reads the hugo file into an array of arrays, @hugos, then reads the genes file one line at a time and checks if the gene name matches any name on any line in the hugo file.

I hope this helps.


In reply to Re: (Failing) script to return an official ID by toolic
in thread (Failing) script to return an official ID by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.