On Thu, 9 Dec 2004 15:01:11 -0500, Li, Aiguo (NIH/NCI) <[EMAIL PROTECTED]> wrote:
[snip] > while(<DATA>) > { > my $mykey; > my $myvalue; > my %Hash; > my %mainhash = (); > > next unless /^SNP/; > %Hash=getkeyvalue($mykey,$myvalue); > > foreach $mykey (keys(%Hash)) > { [snip] > #__DATA__ > #SNP_A-1509443 3 3776202 > #SNP_A_1518557 3 3776202 > #SNP_A_1514538 5 5350951 > #SNP_A_1516403 1 5483872 > #BFFX-BioB-M_at P P P P P A P > #[snip] /^/ matches the start of the string, but your string starts with '#', so you need /^#SNP/ (or just /SNP/, which you use later). You still won't execute the foreach loop, though, because '%Hash=getkeyvalue($mykey,$myvalue)' doesn't do anything, and therefore %Hash has no keys: You pass your function $mykey and $myvalue, but you haven't assigned a value for eaither, so what you would end up with, even if the subroutine were properly formed and returned what you think it returns (see below) would be '%Hash = ([undef],[undef])'. This probably isn't what you want. Also take a look at perldoc perlvar. Inside getkeyvalue, you almost certainly want @_, not $_, but take a look to see why. HTH, --jay savage -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>