Re: Trouble with $key to HASH when Numeric

From: Jim Gibson (jgibson_at_mail.arc.nasa.gov)
Date: 03/04/05

  • Next message: Sergio: "problems using graphviz perl module from apache (windows)"
    Date: Fri, 04 Mar 2005 11:52:35 -0800
    
    

    In article <1109910394.228477.60470@l41g2000cwc.googlegroups.com>,
    CowBoyCraig <simpsonc@us.ibm.com> wrote:

    > It seems if I "Change" the $key going to if ""(exists($GREEN{$key}))""
    > at all It hoses. The keys look like "19973|3.1.A.4" without the quotes.

    Can you be more specific? "hoses" is not a good description of an error
    condition.

    >
    >
    > If I print like this "print GREEN{$key}\n"; to see what the Hash is
    > getting it looks like this:
    > }REEN{12483|3.1.B.2

    Looks like your key has a carriage return ('\r') at the end.

    >
    > That is odd? Is there a way to send my data to the hash without it
    > getting hosed???

    One does not "send data" to a hash. Can you be more specific about what
    you are trying to do?

    >
    > Code below:
    >
    use strict;
    use warnings;

    >
    > foreach (keys %HOT) {
    >
    > # 6AE-23945: 4.1.B.6 # Fix this
    > # Make a Key for %GREEN from %HOT that works
    > my $i=$_;
    > $i=~/(\d{5}?)$/g;

    What do you think this statement is doing? It has a couple of oddities:
    1) the pattern /(\d{5}?)$/ will match zero or one group of 5 digits at
    the end of a string -- in other words, this pattern will always match
    and capture either 5 digits or nothing; 2) the pattern is anchored to
    the end of the string, yet you are asking for all matches with the g
    modifier (there can only be one end of string unless you specify the m
    modifier, which you do not).

    > $i=$1;

    You may have 5 digits in $1, or you may have nothing. You should check
    to see which it is (or fix your regex).

    >
    > my $key="$i|$HOT{$_}";
    > #print "$GREEN{$key}\n";
    >
    > if (exists($GREEN{$key})) {
    > # Remove from %GREEN
    > # remove $KEY and its value from %HASH
    > print "Removed $GREEN{$key}\n";
    > delete($GREEN{$key});
    > } else { # print "did not see\n";
    > }
    > }

    Please post a complete, working program and tell us what you think it
    is doing that it is not. But post it to comp.lang.perl.misc, because
    this newsgroup is defunct.

    ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
    http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
    ---= East/West-Coast Server Farms - Total Privacy via Encryption =---


  • Next message: Sergio: "problems using graphviz perl module from apache (windows)"

    Relevant Pages

    • Re: Entropy in crystalization: up or down?
      ... Strings of digits without context are without ... have short and long blips, as in a Morse Code-type pattern, and these ... any string of digits in pi will be found within any ... artifact behind such patterns. ...
      (talk.origins)
    • Re: Regex question
      ... if I have the following string: ... a pattern of: 2 digits, a slash, 2 more digits, another slass and 4 ... So if your regex ...
      (microsoft.public.dotnet.languages.csharp)
    • Re: regular expressions help
      ... digits, then some text, empty, one alpha character, ... I have the following Regex pattern in my code ... then 1 or 2 digits) from a longer string as long as that pattern is ...
      (microsoft.public.dotnet.languages.csharp)
    • Re: Regex question
      ... if I have the following string: ... a pattern of: 2 digits, a slash, 2 more digits, another slass and 4 ... So if your regex contains it will automatically create grouped values in your match object. ...
      (microsoft.public.dotnet.languages.csharp)
    • Re: Convert a very long int value To Hex
      ... initializer you posted with had more digits, and using that pattern ... If you use a 'ull' or 'ULL' modifier on ...
      (comp.lang.c)