473,545 Members | 2,793 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trouble with $key to HASH when Numeric


It seems if I "Change" the $key going to if ""(exists($GREE N{$key}))""
at all It hoses. The keys look like "19973|3.1. A.4" without the quotes.
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

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

Code below:
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;
$i=$1;

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";
}
}
Craig

Jul 19 '05 #1
2 3244
CowBoyCraig wrote:
It seems if I "Change" the $key going to if ""(exists($GREE N{$key}))""
at all It hoses. The keys look like "19973|3.1. A.4" without the quotes.
Based on your problem, I can see that they are not what you think.
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


That is to be expected when you print a value like "12483|3.1.B.2\ r\n".

You did not use chomp() or other means to get rid of the
unwanted carriage return at the end of the line.

Next time, post to comp.lang.perl. misc instead of comp.lang.perl .

-Joe
Jul 19 '05 #2
In article <11************ *********@l41g2 000cwc.googlegr oups.com>,
CowBoyCraig <si******@us.ib m.com> wrote:
It seems if I "Change" the $key going to if ""(exists($GREE N{$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 =---
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
1976
by: Joakim Storck | last post by:
Hello, Is there any way that I can find the hash value of a class from an instance? >>> class A: .... pass .... >>> a = A() >>> hash(A)
2
20294
by: Mark | last post by:
I'm using an enumerator to iterate through a HashTable that contains all numeric keys. I'd like to iterarate through the HashTable based on the ordered keys. Is there a quick way to do this? Thanks! -Mark IDictionaryEnumerator myEnumerator = myHashTable.GetEnumerator(); while ( myEnumerator.MoveNext() ) { //Please print ordered by Key...
2
6028
by: Me | last post by:
I have a hash (of a hashes) that has data like this table1->table_name ->table_size table2->table_name ->table_size
26
9571
by: JGH | last post by:
How can I check if a key is defined in an associative array? var users = new array(); users = "Joe Blow"; users = "John Doe"; users = "Jane Doe"; function isUser (userID) { if (?????)
21
21117
by: scandal | last post by:
I am a javascript newbie working on a script that checks whether a "path" from one element in an array to another is "blocked." Currently, the script pushes an already processed cell index (hence an integer) into an array. To prevent rechecking already processed cells, the script iterates through the (sorted) array to see whether that...
6
2540
by: Sahil Malik [MVP] | last post by:
Public Private Key Pairs - How do they work? ----------------------------------------------- I was looking at a presentation recently in which it was suggested that - User 1 Encrypts a message using User 2's Public Key. User 2 Decrypts the transmission using his Private Key to get the orignal message. Is the above correct?
13
10107
by: dbuchanan | last post by:
Hello, Here is the error message; ---------------------------- Exception Message: ForeignKeyConstraint Lkp_tbl040Cmpt_lkp302SensorType requires the child key values (5) to exist in the parent table. ----------------------------
4
4988
by: webmaniac | last post by:
Hi, Does anyone knows How "JAVAScript Public Key Encryption" works? I am trying to secure my web page. The users are going to be log in to my website. I want to give them a 4 digit pin, that will match the Private key generated by JAVAScript Public Key Encryption algorithm. Something like that.
5
13314
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL http://mghospedagem.com/images/controlpanel.jpg instead of http://mghospedagem.comhttp://mghospedagem.com/images/controlpanel.jpg As u see, there's the...
0
7432
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7689
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7943
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7456
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7786
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6022
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5076
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1919
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1044
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.