in reply to Re: error returning hash value?
in thread error returning hash value?

Thank you for your time in replying. I'm sorry that I am not very good at asking questions; it isn't easy to know how much detail to include/not include. I always get it wrong :-(. I'll be honest in that I didn't understand what you meant by "To be able to run your code, I first had to remove the filenames from the downloaded files". I put the file names in because the code works on the principle that it reads in all .var files from the directory, so it made sense to me to put a header to say that they were named .var. Sorry if that was wrong.

I have managed to get a bit further with it. I realised that i should have defined my hash as $zygos{$uniqlocus} = $zyg. I also noticed that $locus needed to be non-unique.

I'll figure it out I'm sure. Thank you for your valiant efforts anyway!

Replies are listed 'Best First'.
Re^3: error returning hash value?
by choroba (Cardinal) on Jan 09, 2017 at 08:58 UTC
    > I put the file names in

    Have you ever noticed the "download" link at the bottom of each code section? I clicked it to download the data including tabs, but they included the filenames. Don't make them part of the code section.

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
Re^3: error returning hash value?
by poj (Abbot) on Jan 09, 2017 at 12:54 UTC

    I'm struggling to understand why if you want to 'merge' records from 3 files you are creating hash keys containing the filename ?

    $fields[2] = $file; my $locus = join "\t", @fields[0,1,2,3,4,5];

    From this output code, it looks like you want to create a 'cross tab' with HET/HOM derived from each file in a different column. Is that correct ?

    my $samples_list = join "\t", @samples; print OUT "CHROM POS ID REF ALT QUAL $samples_list

    update : my best guess at what you are trying to do.
Re^3: error returning hash value?
by Anonymous Monk on Jan 09, 2017 at 01:27 UTC
    it isn't easy to know how much detail to include/not include

    Think about: what is the minimum amount of code and sample data needed so that others can reproduce the problem? For each line of code, try removing it - does the problem still exist? If yes, it was ok to remove that line, if the problem goes away, put the line back in. And if removing the line causes a compilation failure, fix that first. See also Short, Self-Contained, Correct Example.

Re^3: error returning hash value?
by Lotus1 (Vicar) on Jan 09, 2017 at 17:26 UTC

    Hi drlecb. There are a few ways to include sample files with your program on Perlmonks. To include it like you did and have the Perl program still be runnable you can add __DATA__ or __END__ after your Perl program and anything after it will be treated as data or comments. Another way is to start a new code section for your sample file with  <c> ... </c> so that the monks can click download for the sample file.

    Here is an example of using __DATA__

    use warnings; use strict; while(<DATA>){ my $line = $_; print $line; } __DATA__ Line 1 Line 2 Line 3