Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: hash with both values and keys unique to each other

by toolic (Bishop)
on Jul 12, 2012 at 17:07 UTC ( #981447=note: print w/replies, xml ) Need Help??

in reply to hash with both values and keys unique to each other

Your code does not compile due to a missing semicolon after the split statement.

$value[0] implies that you have an array named @value, but I only see @val. use strict and warnings (Tip #1 from the Basic debugging checklist)

Replies are listed 'Best First'.
Re^2: hash with both values and keys unique to each other
by perlkhan77 (Acolyte) on Jul 12, 2012 at 17:11 UTC
    Guys this is just a pseudocode to make you understand what the problem really is.

      There are some standard ways to ask questions that elicit positive responses.

      You can use pseudo-code. If you do so, under no circumstances should it look like something a noob whipped up without any thought. One good way to do this is not to write it in any programming language you know. However, even here, variable names must be followable.

      Or you can use a short example of your code. It must be compilable (unless your question is "why doesn't this compile?"). It must be runnable. And it must produce the error scenario you describe. This makes it easy for those who may have an idea on how to help you to actually, you know, help. They can load your code into their debugger, go at it line by line, and possibly give you some insight into your issue. It also helps if you follow some sort of coding standards. It doesn't have to be the One True Brace Style, but it has to be something consistent and has to lend itself to being readable to others. If this all means you need to heavily edit your code before posting, it will at least be obvious that you put some effort in to being helped, making it more likely others will help you. Or at least it won't look like a big ball of mud and that you put no effort into being helped.

      Of course, when you do all that, you'll start to find that you solve your own problem. It might be more work, but it'll solve your issue faster than waiting for some random monk to happen upon your node and take the challenge of helping you with a reply.

      Guys this is just a pseudocode to make you understand what the problem really is.

      Pseudocode with  use strict; use warnings; ?

      Might as well make it real code

      Following is the real code :

      use strict; use Time::HiRes; my $start_time = [Time::HiRes::gettimeofday()]; my (@coordinates,%hash_chr,%HOA,%HOH,%hash_line) = (); open FILE,"GmGm.recent.gff"; while(my $line=<FILE>){ chomp $line; my %seen = (); if($line=~/^(Gm\d{1,})\trecent_duplication\tsyntenic_region\t(\d{1,})\ +t(\d{1,})\t.*\tID\=\w{1,}_Gm\d{1,}\.(Gm\d{1,}.*)\;median_Ks=(.*)\;mat +ches\=(Gm\d{1,}\:\d{1,}\.\.\d{1,})/) { my $chr1 = "$1:$2..$3"; my $ks_val = $5; my $chr2 = $6; if ((exists $hash_chr{$chr2})&&($ks_val > 0.4)){ next; } else{ $hash_chr{$chr1}=$chr2; } } } close FILE;

      And this is how the file looks like

      Gm01 recent_duplication syntenic_region 170877 269340 1 +79 - . ID=A_Gm01.Gm08.2.-;median_Ks=0.1101;matches=Gm08:4628 +8465..46349001 Gm08 recent_duplication syntenic_region 46288465 46349001 + 179 - . ID=B_Gm01.Gm08.2.-;median_Ks=0.1101;matches=Gm01: +170877..269340

        As a side note, you can clean up that regex quite a bit by using + instead of {1,}, and not escaping colons, semi-colons, and equals:

        #if($line=~/^(Gm\d{1,})\trecent_duplication\tsyntenic_region\t(\d{1 +,})\t(\d{1,})\t.*\tID\=\w{1,}_Gm\d{1,}\.(Gm\d{1,}.*)\;median_Ks=(.*)\ +;matches\=(Gm\d{1,}\:\d{1,}\.\.\d{1,})/) if($line=~/^(Gm\d+)\trecent_duplication\tsyntenic_region\t(\d+)\t(\ +d+)\t.*\tID=\w+_Gm\d+\.(Gm\d+.*);median_Ks=(.*);matches=(Gm\d+:\d+\.\ +.\d+)/)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://981447]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2018-03-20 00:48 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (247 votes). Check out past polls.