Celticrose777 has asked for the wisdom of the Perl Monks concerning the following question:

Hello all! I'm a student whose learning perl in a class. and i have an assignment due tomorrow (i kno very last min!) Our assignment is to use a hash which from what i can understand is a key and value relationship. Anyway our assignment is to use the .txt file which contains the strain name and extract the matching sequence of the strain name from the .fasta file. so the "key" is from the .txt file and the "value" is from the .fasta file. If anyone could help me that would be much appreciated!!! For the .txt file here is the header: Strain Name Subtype Collection Date State / Province Country Host Host Gender Host Age Vaccination Status Sensitive Drug Information Resistant Drug Information and there is a list of strains at the bottom.

Replies are listed 'Best First'.
Re: Need Help with Hashs plz!
by moritz (Cardinal) on Mar 07, 2011 at 14:55 UTC
Re: Need Help with Hashs plz!
by CountZero (Bishop) on Mar 07, 2011 at 15:57 UTC
    i kno very last min!
    if it wasn't for deadlines, nothing would get done.

    But seriously, some more things you will have to look into:

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Re: Need Help with Hashs plz!
by raybies (Chaplain) on Mar 07, 2011 at 16:01 UTC

    As noted by previous posters you'll want to read more than expect answers, like perlintro.

    Chances are your solution will have the following form:

    Open file While the file has lines, read a line of text. { Split the line of text into useful pieces. Save each corresponding field into your desired data structure (in + this case, a hash). } print data (perhaps in another loop foreach of your keys)

    You may then attempt to print each line, perhaps after ordering the keys, etc. The cool thing is you've got a lot of flexibility, and Perl makes it easy to make quick changes and see the results immediately.

    Start simple, and then tweak it. In a few hours, I think you'll be surprised at all the fun you're having.

    Good luck, and next time don't put it off til the last second--because you're really short-changing yourself hours of sheer joy and programming ecstasy that comes with using Perl. (I can understand if you had some ball-n-chain language (like Ruby, C# or Java) you had to deal with why you'd want to put it off til the last second... but not Perl!) Best regards,

    --Ray

Re: Need Help with Hashs plz!
by toolic (Bishop) on Mar 07, 2011 at 14:56 UTC
    perlintro discusses some basics about hashes and reading input from a file. Read through that short intro, write some code, then, if you still have problems, post your code with a small sample of your input data, and ask detailed questions.
Re: Need Help with Hashs plz!
by planetscape (Chancellor) on Mar 09, 2011 at 01:04 UTC