Re: populating a hash slice from a filehandle

2008-06-23 Thread Jay Savage
On Fri, Jun 20, 2008 at 4:52 PM, Bryan R Harris [EMAIL PROTECTED] wrote: Bryan R Harris wrote: John W. Krahn wrote: Bryan R Harris wrote: John W. Krahn wrote: The left hand side of the assignment determines context so the @l2r{...} part. That strikes me as odd... When perl goes to

Re: populating a hash slice from a filehandle

2008-06-23 Thread Bryan R Harris
From: Bryan R Harris [EMAIL PROTECTED] Bryan R Harris wrote: John W. Krahn wrote: Bryan R Harris wrote: John W. Krahn wrote: The left hand side of the assignment determines context so the @l2r{...} part. That strikes me as odd... When perl goes to populate @l2r{a,b}, it seems

Re: populating a hash slice from a filehandle

2008-06-23 Thread Jenda Krynicky
From:Bryan R Harris [EMAIL PROTECTED] Jenda wrote: From: Bryan R Harris [EMAIL PROTECTED] It makes more sense to me that (FILE,FILE) is kind of the same thing as saying (@a,@b). In list context @a returns the array as a list, but in scalar context @a returns the number of elements.

Re: populating a hash slice from a filehandle

2008-06-21 Thread Jenda Krynicky
From: Bryan R Harris [EMAIL PROTECTED] Bryan R Harris wrote: John W. Krahn wrote: Bryan R Harris wrote: John W. Krahn wrote: The left hand side of the assignment determines context so the @l2r{...} part. That strikes me as odd... When perl goes to populate @l2r{a,b},

Re: populating a hash slice from a filehandle

2008-06-20 Thread Bryan R Harris
Bryan R Harris wrote: John W. Krahn wrote: Bryan R Harris wrote: Jenda Krynicky wrote: Context. The FILEHANDLE returns a single line in scalar context and a list of all lines in a list context. And there is no such thing as a two-item-list context. So in the first case the

Re: populating a hash slice from a filehandle

2008-06-20 Thread John W. Krahn
Bryan R Harris wrote: John W. Krahn wrote: Bryan R Harris wrote: John W. Krahn wrote: The left hand side of the assignment determines context so the @l2r{...} part. That strikes me as odd... When perl goes to populate @l2r{a,b}, it seems to me that it would go through this process: -

Re: populating a hash slice from a filehandle

2008-06-20 Thread Bryan R Harris
Bryan R Harris wrote: John W. Krahn wrote: Bryan R Harris wrote: John W. Krahn wrote: The left hand side of the assignment determines context so the @l2r{...} part. That strikes me as odd... When perl goes to populate @l2r{a,b}, it seems to me that it would go through this

Re: populating a hash slice from a filehandle

2008-06-19 Thread Bryan R Harris
From: Bryan R Harris [EMAIL PROTECTED] Given an open filehandle, why don't these two things do the same thing? ** @l2r{a,b} = (FILE, FILE); $c = FILE; ** $l2r{a} = FILE; $l2r{b} = FILE; $c = FILE;

Re: populating a hash slice from a filehandle

2008-06-19 Thread John W. Krahn
Bryan R Harris wrote: From: Bryan R Harris [EMAIL PROTECTED] Given an open filehandle, why don't these two things do the same thing? ** @l2r{a,b} = (FILE, FILE); $c = FILE; ** $l2r{a} = FILE; $l2r{b} = FILE; $c = FILE;

Re: populating a hash slice from a filehandle

2008-06-19 Thread Bryan R Harris
Bryan R Harris wrote: From: Bryan R Harris [EMAIL PROTECTED] Given an open filehandle, why don't these two things do the same thing? ** @l2r{a,b} = (FILE, FILE); $c = FILE; ** $l2r{a} = FILE; $l2r{b} = FILE; $c

Re: populating a hash slice from a filehandle

2008-06-19 Thread John W. Krahn
Bryan R Harris wrote: John W. Krahn wrote: Bryan R Harris wrote: Jenda Krynicky wrote: Context. The FILEHANDLE returns a single line in scalar context and a list of all lines in a list context. And there is no such thing as a two-item-list context. So in the first case the assignment to

populating a hash slice from a filehandle

2008-06-18 Thread Bryan R Harris
Given an open filehandle, why don't these two things do the same thing? ** @l2r{a,b} = (FILE, FILE); $c = FILE; ** $l2r{a} = FILE; $l2r{b} = FILE; $c = FILE; ** The first seems to be

Re: populating a hash slice from a filehandle

2008-06-18 Thread Jeff Peng
On Thu, Jun 19, 2008 at 5:50 AM, Bryan R Harris [EMAIL PROTECTED] wrote: Given an open filehandle, why don't these two things do the same thing? ** @l2r{a,b} = (FILE, FILE); $c = FILE; because @l2r{...} is a list, right? so the statement above is in a

Re: populating a hash slice from a filehandle

2008-06-18 Thread Jenda Krynicky
From: Bryan R Harris [EMAIL PROTECTED] Given an open filehandle, why don't these two things do the same thing? ** @l2r{a,b} = (FILE, FILE); $c = FILE; ** $l2r{a} = FILE; $l2r{b} = FILE; $c = FILE;

Re: populating a Hash

2006-02-19 Thread John W. Krahn
David Gilden wrote: Good morning, Hello, I would like to populate a hash from a csv text file, Do you really think that you need to? then test for the existence of a value in the hash. A value? Or a key? perldoc -f exists If not found return an error message and exit. ithe text

populating a Hash

2006-02-18 Thread David Gilden
Good morning, I would like to populate a hash from a csv text file, then test for the existence of a value in the hash. If not found return an error message and exit. ithe text file will have the format of: # whitelist created 2/18/06 or some other comment on the first line name1,nick1 ---

Re: populating a Hash

2006-02-18 Thread Hans Meier (John Doe)
David Gilden am Samstag, 18. Februar 2006 16.29: Good morning, Good evening here ;-) I would like to populate a hash from a csv text file, then test for the existence of a value in the hash. If not found return an error message and exit. ithe text file will have the format of: # whitelist

Re: populating a hash with % used as the key and F string as the value

2005-05-04 Thread John Doe
Am Dienstag, 3. Mai 2005 23.42 schrieb [EMAIL PROTECTED]: John, I am a lotus user so my top-down reply is default ...sorry. Don't know Lotus. No possibilities to change defaults there? ;-) I think all looks good, but I have to ask why are you initializing an array to hold values of a hash

Re: populating a hash with % used as the key and F string as the value

2005-05-03 Thread DBSMITH
:37 cc AM Subject Re: populating a hash with % used

Re: populating a hash with % used as the key and F string as the value

2005-05-02 Thread John Doe
Am Montag, 2. Mai 2005 03.49 schrieb [EMAIL PROTECTED]: John, the reg exp s -+ (); ^ was changed to y/sg//;; y/-//d; s{\w+} (); to exclude the spaces and use y... thx why are thre operators y or tr more efficient since these operators

Re: populating a hash with % used as the key and F string as the value

2005-05-02 Thread John Doe
Am Montag, 2. Mai 2005 09.44 schrieb John Doe: Am Montag, 2. Mai 2005 03.49 schrieb [EMAIL PROTECTED]: John, the reg exp s -+ (); ^ was changed to y/sg//;; y/-//d; s{\w+} (); to exclude the spaces and use y... thx why are

Re: populating a hash with % used as the key and F string as the value

2005-05-02 Thread John W. Krahn
[EMAIL PROTECTED] wrote: John, the reg exp s -+ (); ^ was changed to y/sg//;; y/-//d; s{\w+} (); to exclude the spaces and use y... thx why are thre operators y or tr more efficient since these operators do not use pattern matching? Originally I

Re: populating a hash with % used as the key and F string as the value

2005-05-02 Thread John W. Krahn
John Doe wrote: Am Montag, 2. Mai 2005 03.49 schrieb [EMAIL PROTECTED]: John, the reg exp s -+ (); ^ was changed to y/sg//;; y/-//d; s{\w+} (); to exclude the spaces and use y... thx why are thre operators y or tr more efficient since these

Re: populating a hash with % used as the key and F string as the value

2005-05-02 Thread DBSMITH
* If the format of all your data lines is consistent, you could use split on \s+ to get the data fields instead of a tr/m cascade. * Then, if I understand you correctly, you wantto build a hash with % keys and F... values. This could be done with code like push @{$lookup_hash{$pct_value}},

Re: populating a hash with % used as the key and F string as the value

2005-05-02 Thread John Doe
Am Dienstag, 3. Mai 2005 03.30 schrieb [EMAIL PROTECTED]: * If the format of all your data lines is consistent, you could use split on \s+ to get the data fields instead of a tr/m cascade. * Then, if I understand you correctly, you wantto build a hash with % keys and F... values.

populating a hash with % used as the key and F string as the value

2005-05-01 Thread DBSMITH
I was thinking of using a hash of arrays b/c I want to look-up each array by a certain string and that string would the % string. My goal is to populate a hash of some sort with the % string and its associated F string. Here is the data file: 1 2005/01/20 15:39 17 2% -il-o-b- sg

Re: populating a hash with % used as the key and F string as the value

2005-05-01 Thread John W. Krahn
[EMAIL PROTECTED] wrote: I was thinking of using a hash of arrays b/c I want to look-up each array by a certain string and that string would the % string. My goal is to populate a hash of some sort with the % string and its associated F string. Here is the data file: 1 2005/01/20 15:39 17

Re: populating a hash with % used as the key and F string as the value

2005-05-01 Thread DBSMITH
Subject Re: populating a hash with % used as the key and F string as thevalue

populating a hash key using a variable

2002-12-11 Thread Ian Zapczynski
Hello all, I'm obviously making a silly mistake here and would appreciate it if someone can point out my error. I am trying to populate a hash of a hash in a while() loop. Here is what I have: my $i = 0; my %hash = (); while (EXPR) { $hash{SOMETHING}{$i} = $something;

RE: populating a hash key using a variable

2002-12-11 Thread Kipp, James
Hello all, I'm obviously making a silly mistake here and would appreciate it if someone can point out my error. I am trying to populate a hash of a hash in a while() loop. Here is what I have: my $i = 0; my %hash = (); while (EXPR) { $hash{SOMETHING}{$i} = $something;

Re: populating a hash key using a variable

2002-12-11 Thread Ian Zapczynski
I am not populating from a file, actually. I'm populating from the output of $sth-fetch from DBI. The $something and $something_else variables in this case are numbers which have been defined by the output of that method. If I do $hash{SOMETHING}{0} = $something; Then my hash is populated

RE: populating a hash key using a variable

2002-12-11 Thread Kipp, James
If I do $hash{SOMETHING}{0} = $something; Then my hash is populated correctly. I am only not getting results if I do $hash{SOMETHING}{$i} = $something. The key here is how I am using the variable $i in my hash. I tried this on my machine and it worked fine: my $i; for ( 1..5 ) {

Re: populating a hash key using a variable

2002-12-11 Thread Rob Dixon
11, 2002 4:11 PM Subject: RE: populating a hash key using a variable If I do $hash{SOMETHING}{0} = $something; Then my hash is populated correctly. I am only not getting results if I do $hash{SOMETHING}{$i} = $something. The key here is how I am using the variable $i in my hash

Re: populating a hash key using a variable

2002-12-11 Thread Ian Zapczynski
:-} Cheers, Rob - Original Message - From: Kipp, James [EMAIL PROTECTED] To: 'Ian Zapczynski' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, December 11, 2002 4:11 PM Subject: RE: populating a hash key using a variable If I do $hash{SOMETHING}{0} = $something; Then my hash

populating a hash from a text file

2001-11-21 Thread Kenneth Singleton
Yes, I know this should be very easy. Yes I've seen the exercise in Learning Perl. Still I can't get the darned thing to work. Please help me.

Populating a hash

2001-11-21 Thread Kenneth Singleton
I'm trying to do those time honored exercises from the llama book and having some trouble. This is the subroutine I'm using: sub init_words { while ($filename = *.secret) { open (WORDSLIST, $filename) || die can't open $filename: $!; if (-M WORDSLIST 7.0) { while ($name =

RE: populating a hash from a text file

2001-11-21 Thread KENDER, TED (AIT)
PROTECTED] Subject: populating a hash from a text file Yes, I know this should be very easy. Yes I've seen the exercise in Learning Perl. Still I can't get the darned thing to work. Please help me. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: populating a hash from a text file

2001-11-21 Thread Randal L. Schwartz
Kenneth == Kenneth Singleton [EMAIL PROTECTED] writes: Kenneth Yes, I know this should be very easy. Yes I've seen the Kenneth exercise in Learning Perl. Still I can't get the darned Kenneth thing to work. Please help me. What have you tried? Does this example help? my %lastname;