3 field hash, value lookup by key is 2nd field

Goal- look up value in a hash of 3 fields where middle is key field for
lookup. The build hash from text file part below is working fine.
Then I read in a transaction file with field $sicode which should
lookup/chain/match to the key ($sig)in the hash and find a weight (3rd field
in hash, $wgt), and a code, $type(1st field).
I can't get the basic lookup on key $sig to work.

I have created the hash from a text file thusly

while (<INFILE>) {
   ($type,$sig, $wgt) = split ','; # splits $_ by default
   chomp $wgt;
   print "2 $type   $sig   $wgt \n";# single-spaced output
   $sigwgthash{$sig}{'type'} = $type;
   $sigwgthash{$sig}{'wgt'} = $wgt;
    }
-------
then verified its' existance in memory and can print each field by doing

 foreach $key (sort keys %sigwgthash) {
   print "$key has a wgt of $sigwgthash{$key}{'wgt'} \n";
--------
Now  why is it so hard to find a basic "lookup value by key" using key field
from another file??  But remember, the key I need to use is the MIDDLE of
the 3 fields in the hash.

When trying a distinct lookup within a "foreach" read of the non-hash
transaction file, .  I tried..
print "wgthash $wgthash     sigwgt $sigwgthash{$sicode}{'wgt'}     \n";

where $sicode is the field from the other file to be matched in the hash
keys.  The other words in front are just to describe field in that debug
print line.
I get blanks/nothing... no match evidently.

Most tutorials, Perl Monks, etc do not seem to cover many basics one notch
above the most basic. I personally found the Programming Perl/Oreilly book
to be NOT very helpful.
Sure would appreciate any help.
RS



0
Buyersg
4/27/2002 6:27:51 AM
perl.beginners 29381 articles. 4 followers. Follow

1 Replies
555 Views

Similar Articles

[PageSpeed] 11

On Friday, April 26, 2002, at 11:27  PM, r wrote:

> Goal- look up value in a hash of 3 fields where middle is key field for
> lookup. The build hash from text file part below is working fine.
> Then I read in a transaction file with field $sicode which should
> lookup/chain/match to the key ($sig)in the hash and find a weight (3rd 
> field
> in hash, $wgt), and a code, $type(1st field).
> I can't get the basic lookup on key $sig to work.
>
> I have created the hash from a text file thusly
>
> while (<INFILE>) {
>    ($type,$sig, $wgt) = split ','; # splits $_ by default
>    chomp $wgt;
>    print "2 $type   $sig   $wgt \n";# single-spaced output
>    $sigwgthash{$sig}{'type'} = $type;
>    $sigwgthash{$sig}{'wgt'} = $wgt;
>     }
> -------
> then verified its' existance in memory and can print each field by doing
>
>  foreach $key (sort keys %sigwgthash) {
>    print "$key has a wgt of $sigwgthash{$key}{'wgt'} \n";
> --------
> Now  why is it so hard to find a basic "lookup value by key" using key 
> field
> from another file??  But remember, the key I need to use is the MIDDLE of
> the 3 fields in the hash.
>
> When trying a distinct lookup within a "foreach" read of the non-hash
> transaction file, .  I tried..
> print "wgthash $wgthash     sigwgt $sigwgthash{$sicode}{'wgt'}     \n";
>
> where $sicode is the field from the other file to be matched in the hash
> keys.  The other words in front are just to describe field in that debug
> print line.
> I get blanks/nothing... no match evidently.

nothing wrong with your code that i can see.
what do you mean 'read of the non-hash' file? a different file than the 
one you created the hash from?
what is in that file?
maybe you need to give us the code where you get nothing. the one line you 
are showing is ok in itself.
assuming you have a valid key in $sicode.

> Most tutorials, Perl Monks, etc do not seem to cover many basics one notch
> above the most basic. I personally found the Programming Perl/Oreilly book
> to be NOT very helpful.
> Sure would appreciate any help.
> RS
>
>
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
>

0
rdacker
4/28/2002 6:36:53 PM
Reply:

Similar Artilces:

Compare a field to what a value would be if it were in that field
We have been caught more than once with an error that's easy to fall into, described below. What I would like is something like is a way to treat a value as it would be if it were assigned to an existing database column, e.g. WHERE field = CAST(value AS TYPEOF(field)) or maybe some field matching operator that implicitly casts the value to the fields type before the comparison, e.g. WHERE field MATCHES value The problem we hit can be happen in SQL or in the invoking application, but it goes something like: <pseudocode GripeAboutSyntax="OFF">...

How can I add 2 fields value to 1 fields value in a GridView?
Hi all!I have one access database named=Medlemmar.mdb and Tablename=TidBokning and with some columns ex. "Bokad_For" and "Plats".Let say that "Bokad_For" contains value "Group2" and "Plats" contains value "Stockholm".Now I want to make this 2 value to 1 fileds like this: "Bokad_For" contains value "Group2Stockholm"How can I do that?I use asp.net 2.0 and C#.I tried with Eval("Bokad_For") and somthing, but Eval works only in Templates (I guess) I cant get Templates to work in my GridView.i'm newbee in this and think I need some help here :-) ?Thanks for all help!Micael Roxenhall You can sol...

Selecting value in one field then causes value in another field to be selected.
I have a web form which contains a date field, the date is populated using a DatePicker which is Javascript based. The form also has a drop down box containing 3 values. What I want to do is when a date has been selected that this will cause the dropdown list value to change to dated which is one of its 3 values. i.e. when the date field is not blank then the value will be selected in the dropdown. What I also want to happen is when the date has been selected and the dropdown value is dated then the date field and the dropdown field will be set to read only.Anyone any ideas how to this usin...

Field that controls the values that appear in this field
--_009_EEA7F24FEA5EDC42BC3FD72846A5D8F84138437CAMSPRD0711MB593_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi, Can I use the option of "Field that controls the values that appear in this= field" for non-custom fields? Thanks, Shalom. Shalom Shevach | QA Manager Comigo Ltd. O: +972- 9-771-5090 Ext. 119 | F: +972- 9-771-5091 | www.comigo.com<http= ://www.comigo.com/> E-mail: shalom.shevach@comigo.com<mailto:shalom.shevach@comigo.com> [Description: Description: Comigo]<http://comigo.com/&...

how to pass field value to another field
how can i take an id field value from one table and insert it to a field in another table? my insert for document is this: const string sql = "INSERT INTO document(doc_id, doc_name) VALUES(doc_id, doc_name)"; my insert for staff data: success = (int)ApplicationBLL.InsertData(staff_name, staff_loc); each staff must be linked to one document. therefore i have staff_id in both tables. staff_id (pk with identity seed) in staff table and staff_id in document table. But when i run application it says cannot insert null into staff_id in document. could I hardcode it to pass staff_id f...

Field that controls the values that appear in this field...
SGVsbG8gRXZlcnlib2R5IQ0KDQpJJ20gd29ya2luZyBvbiBpbXBsZW1lbnRpbmcgYSBuZXcgaW5z dGFuY2Ugb2YgQlogNC40LjIgSSBuZWVkIHRvIGFkZCB0aGUgZm9sbG93aW5nIGZpZWxkczoNCg0K MS4gRGlzdHJpY3QNCjIuIFNjaG9vbCBEZXBlbmRzIG9uIERpc3RyaWN0DQozLiBUZWFjaGVyICBE ZXBlbmRzIG9uIFNjaG9vbA0KDQpJIGNvdWxkIGRvIHRoZSBSZWxhdGlvbnNoaXAgYmV0d2VlbiB0 aGVtLCBidXQgdGhlIGlzc3VlIGlzIEkgaGF2ZSBsaWtlIDUwMCsgdGVhY2hlcnMsIHNvIHdoZW4g SSB0cmllZCB0byBjcmVhdGUgYSBidWcgaXQgdGFrZXMgYSBsb25nIHRpbWUgYW5kIEkgaGF2ZSBl cnJvciBvbiB0aGUgY2hyb21lLCBJIGd1ZXNzIGlzIGZvciB0aGUgYW1vdW50IG9mIGluZm8gb24g Y2ZfdGVhY2hlciB0YWJsZS4NCg0KSXMgdGhlcmUgYSB3YXkgSSBjYW...

Change value of a field from a Computed Field
Hi all ! I need to put a value to a one field from a computed field. I try this in the expression of computed field: ( field_to = value of computed field_from) But the result is "TRUE" or "FALSE". My question: the computed field is able to modify a value of another field ? How i do this ? (If possible) Thanks in advance. Alessandro Hass If you are asking if you can place a value in the primary buffer using only datawindow expressions, the answer is no. You will have to do this in script. If you just want to display something when another fi...

Custom field controlled by other fields value
Hi i want to create a custom field with values shared by only 2 or 3 products for example. the only way i found is to duplicate this value 3 times (numbers of products having this field value). this is impossible because there is a constraint on the value of the custom field on the database. do you think that i can drop the constraint concerning this field from the database? Thanks a lot Fida On 10/22/2010 07:32 AM, fida wrote: > do you think that i can drop the constraint > concerning this field from the database? No, Bugzilla will not function properly with dupl...

Gridview Hyperlink Field needs to include value from a previous gridview and a field value
Hi all Hope you can help, here is what I'm trying to do. I have a gridview on a page that contains a value (PracticeCode) I use this value as a parameter to filter an additional GridView (Gridview2). Now what I also want to do is take that value (PracticeCode) and use it in as part of the URL for a hyperlink field in GridView2 concatenatint it with the value of a Gridview field called Documentname so that: Hyperlink field URL Is "/store/" & PracticeCode & "/" and DocumentName Anyone know how to do this  regards chubsterit wasn't me, ...

Creating Custom Fields dependent on Component field in Bugzilla version 3.6.3
Hi, My requirement is that i need to create some Custom fields which are dependent on the "Component" field in Bugzilla. Our team is using Bugzilla version 3.6.3 Is it possible to do this using the Administration link or i will have to make code level changes. If field level changes are to be made then just needed to understand the file from where the list for Fields is populated. Awaiting for your reply on this. Thanks. Regards, Avin M. ...

gridview1 and edit coulumn and hyperlinfield and datanavigate url fields and navigateurlformatstring ? i know for one field.. how can i send 3 field ??
 hi friends gridview1 and edit coulumn and hyperlinfield and datanavigate url fields and navigateurlformatstring ? page.aspx?urunnumarasi={0}kategori={1}kategori1={2}kategori2={3} is my navigateurlfomatstring is it true ? what should i write for datanivate url fields cheersMark as me if my question or my answer can be helpful for you :) Assuming the names used in the QueryString are your parameters, you'd do something like this: <asp:hyperlinkfield datanavigateurlfields="urunnumarasi,kategori,kategori1,kategori2" datanavigateurlformatstring="page.as...

DetailsView: conditionally hide field if value == null, but can't update the value of other fields
Hi, I need help please. I have made some fields hidden if their value is null by setting visible to false on the DetailsView1_Itemcreated event. I put the field's to the DataKeyNames, so that I can check the value is null or not when detailsview is at the readOnly mode.But, when I tried to edit, it throws an error: must declare a scalar for @...  so, i add some code in the DetailsView1_ItemUpdating: e.newValues["color"] = null; then the error is gone. but, the values for other fields are not updated. I already check the e.newValues["other fields"] , they all are ...

Using a Session field as default field value
Hi all, I am brand new to ASP.NET, this is my first post here. I have build a form, with a Formview control, set to Insert item. That page will be used to add record to a database. I have a field called "Listing_Owner" which will store the Authentified user name. I know how to get the User name, but I just don't know how to set the Username as default value for that owner field, which will be hidden. I tried to write code in the Page_Load event, but it does not seems to find my field. Any idea? I hope it is clear, this is all new terms for me. Thanks alot.  New to ASP... loo...

Updating a table field with a computed field value
In a datawindow, how do I update a field in a table with the value from a computed field ? Thank you. Joe Thank you very much. That's the answer I was looking for. Joe Ippolito In updatestart , or in update button, you can use getitem() and setitem() functions to get the value and set it in field. You can't achieve this directly in datawindow. hth -- Mahendra Dhamdhere Unicef, New York Email:mahendrad@hotmail.com Joseph Ippolito wrote: > In a datawindow, how do I update a field in a table with the value > from a > computed field ? Thank ...

Web resources about - 3 field hash, value lookup by key is 2nd field - perl.beginners

Lookup A Cell Phone Number Dot Com
Lookup cell phone numbers by name or reverse lookup cell phone number to find name and address.

DNS Lookup - Everything to do with DNS, DDNS, and Free Services
December 23, 2011 admin DDNS , Dynamic Dns , 0 There are about a billion dynamic dns vanity hostnames available, so it is a very difficult exercise ...

Pet Microchip Lookup - Powered by AAHA
Instructions: Enter the microchip ID above and click "Submit". Enter only the 9, 10 or 15 character microchip number, with no punctuation or ...

Publishers List - Welcome to Publisher Lookup UK.
Many people find it difficult to access the world of books. Whether through dyslexia, visual impairment or motor difficulties, thousands of ‘would ...

Lookup table - Wikipedia, the free encyclopedia
In computer science , a lookup table is an array that replaces runtime computation with a simpler array indexing operation. The savings in terms ...

Voter Lookup
Mail to: Tarrant County Elections office, 2700 Premier St., Ft. Worth, Tx 76111 or fax to 817-831-6475, Attn: Web Opt-out.

Cell Phone Lookup Emporium - Home
Cell Phone Lookup Emporium Home Free Cell Phone Lookup Resource Connections We have spent some considerable time identifying websites with valuable ...

DNS Lookup
Without DNS (domain name system) we would not be able to use our favourite websites such as Facebook and Twitter, nor would we be able to check ...

Facebook Adds 25 New Preferred Developer Consultants, Improves PDC Lookup Tool
... number of developers in the PDC Directory to 90. It also added expertise filters to a newly launched version of the Preferred Developer Lookup ...

Search Twitter - LOOKUP
Sign in Sign up Search Refresh emyri d. @ LookUP_itsMoine 24m love and hip hop tonight 😁 View details · Martin Miles @ martincmiles 34m This ...

Resources last updated: 11/30/2015 6:50:28 AM