Dear all,

I've done some reading and it sounds like it is possible to have numeric hash keys and perl is supposed to figure out when numbers should act as numbers and when they should act as strings. However, I am getting an error message that indicates to me that it thinks my numbers are strings. Any advice appreciated. Thanks

use strict; use warnings; use Data::Dumper; ############################ my $inGNPS="MsRtLib_all.tab"; open(IN,$inGNPS); my %HoPMAnnot; my %HoPMrtAnnot; while(my $line=<IN>){ chomp $line; my ($ParMass,$RT,$annot)=split(/\t/,$line); $HoPMAnnot{$ParMass}=$annot; $HoPMrtAnnot{$ParMass}{$RT}=$annot; } close(IN); print Dumper (%HoPMAnnot); ###### my $inATdat="consensus_features_extracted.csv"; open(IN,$inATdat); while(my $line=<IN>){ chomp $line; next if($line =~/^,/); # header starts with comma my ($feat_numb,$mz_min,$mz_max,$rt_min,$rt_max,$quality,$inten +sity)=split(/,/,$line); foreach my $PM (keys %HoPMAnnot){ if ($PM <=$mz_max && $PM >=$mz_min){ print join("\t",$line,$HoPMAnnot{$PM})."\n"; } } } close(IN);

data dumper output

$VAR1 = '272.043'; $VAR2 = 'N/A'; $VAR3 = '272.188'; $VAR4 = 'N/A'; $VAR5 = '838.844'; $VAR6 = 'Sodium_Formate'; $VAR7 = '601.393'; $VAR8 = 'N/A';

error

Argument "parent mass" isn't numeric in int at checkTheoFeat4GNPSannot.pl line 25, <IN> line 1034.


In reply to numeric hash keys by AWallBuilder

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.