I have a FASTA array and I need to make it into a hash in order to look for an specific ID and get that specific sequence, any ideas this is what I have until now and i know im not good with Perl by trying hard

#!/usr/local/bin/perl #the file name $filename= hwk2.seq; use strict; use warnings; use lib '/class/bi617a/share/textbook'; use BeginPerlBioinfo; #Declare initialize the variables my @file_data=(); my $sequence= ''; my $query= ''; my %hash= ''; #Read the contents of the file hwk3.seq @file_data=get_file_data("hwk2.seq"); #Extract the sequence data from the content; %hash= map {$_ => 1 } @file_data; if (exists $hash{$query}){ print "This is sequence: $sequence"; }else { print "Not and ID"}; exit; sub get_file_data{ my($filename) = @_; use strict; use warnings; unless ( open (GET_FILE_DATA, $filename) ) { print STDERR "Cannot open file \"$filename\"\n\n"; exit; } @filedata= <GET_FILE_DATA>; close GET_FILE_DATA; return @filedata; }

In reply to New to Perl by rolandomantilla

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.