Re: Trouble with $key to HASH when Numeric
From: Jim Gibson (jgibson_at_mail.arc.nasa.gov)
Date: 03/04/05
- Previous message: Joe Smith: "Re: Trouble with $key to HASH when Numeric"
- In reply to: CowBoyCraig: "Trouble with $key to HASH when Numeric"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 =---
- Previous message: Joe Smith: "Re: Trouble with $key to HASH when Numeric"
- In reply to: CowBoyCraig: "Trouble with $key to HASH when Numeric"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|