Re: arrays and hashes

2003-06-07 Thread James Edward Gray II
On Friday, June 6, 2003, at 07:05 PM, R. Joseph Newton wrote: The point here is that the essential purpose of the key is that of a pointer, rather thanas data in itself. There are applications of a Perl hash where one does not even need to use the value, finding all the unique words in a documen

Re: arrays and hashes

2003-06-07 Thread Rob Dixon
R. Joseph Newton wrote: > Rob Dixon wrote: > > > James Edward Gray II wrote: > > > On Friday, June 6, 2003, at 03:32 AM, R. Joseph Newton wrote: > > > > > > > The player's name IS the number. No other numbering system is > > > > needed. The players name is NEVER stored in the hash, AFAIK. The >

Re: arrays and hashes

2003-06-07 Thread Rob Dixon
R. Joseph Newton wrote: > Rob Dixon wrote: > > > James Edward Gray II wrote: > > > On Friday, June 6, 2003, at 03:32 AM, R. Joseph Newton wrote: > > > > > > > The player's name IS the number. No other numbering system is > > > > needed. The players name is NEVER stored in the hash, AFAIK. The >

Re: arrays and hashes

2003-06-06 Thread R. Joseph Newton
Rob Dixon wrote: > James Edward Gray II wrote: > > On Friday, June 6, 2003, at 03:32 AM, R. Joseph Newton wrote: > > > > > The player's name IS the number. No other numbering system is > > > needed. The players name is NEVER stored in the hash, AFAIK. The > > > name is used to feed a hashing f

Re: arrays and hashes

2003-06-06 Thread R. Joseph Newton
James Edward Gray II wrote: > On Friday, June 6, 2003, at 03:32 AM, R. Joseph Newton wrote: > > > The player's name IS the number. No other numbering system is > > needed. The players name is NEVER stored in the hash, AFAIK. The > > name is used to feed a hashing function, which renders an ind

Re: arrays and hashes

2003-06-06 Thread R. Joseph Newton
"R. Joseph Newton" wrote: > Stuart White wrote: > > > This does make it clearer, but not entirely. Is this > > what is happening: the loop starts, and goes > > immediately into the if statement. when the regex > > finds a line with "Jump Shot" it stores that in $2, > > and the player name in $1.

Re: arrays and hashes

2003-06-06 Thread Rob Dixon
James Edward Gray II wrote: > On Friday, June 6, 2003, at 03:32 AM, R. Joseph Newton wrote: > > > The player's name IS the number. No other numbering system is > > needed. The players name is NEVER stored in the hash, AFAIK. The > > name is used to feed a hashing function, which renders an inde

Re: arrays and hashes

2003-06-06 Thread James Edward Gray II
On Friday, June 6, 2003, at 03:32 AM, R. Joseph Newton wrote: The player's name IS the number. No other numbering system is needed. The players name is NEVER stored in the hash, AFAIK. The name is used to feed a hashing function, which renders an index into the storage of the hash structure.

Re: arrays and hashes

2003-06-06 Thread R. Joseph Newton
Stuart White wrote: > This does make it clearer, but not entirely. Is this > what is happening: the loop starts, and goes > immediately into the if statement. when the regex > finds a line with "Jump Shot" it stores that in $2, > and the player name in $1. The next thing it does, > and I'm not

Re: arrays and hashes

2003-06-06 Thread R. Joseph Newton
Stuart White wrote: > Ok, I think I get it. the $_ is printing the player > name, (though I don't know why I'm not using $1 $1 is a special-purpose variable used only in relation to regexes. The default variable for looping structures will be contained in $_. > > instead for that) and the $line

Re: arrays and hashes

2003-06-06 Thread R. Joseph Newton
Stuart White wrote: > Hey, thanks that worked! > > --- James Edward Gray II <[EMAIL PROTECTED]> > wrote: > > > I don't seen any reason to use the array at all, so > > I've removed it. > > If you had one that I just didn't know about, send > > it on back. > > That's how I tried to solve this piece

Re: arrays and hashes

2003-06-06 Thread R. Joseph Newton
Stuart White wrote: > > Right now my array is just like that, minus the > numbers. So what I want to do is assign the array to > a hash. If I were to do that, my understanding is > that the names would be keys and the numbers values, > and doing such an assignment in a loop would cause > some en

Re: More Jump Shots ;-) [Was Re: arrays and hashes]

2003-06-04 Thread Kevin Pfeiffer
In article <[EMAIL PROTECTED]>, Tassilo Von Parseval wrote: [...] > If you from then on referred to elements of the hash with something like > > $score_ref->{ key }; > > then this would be it. It depends on what you want. By dereferencing the > whole data-structure you're essentially creating

Re: More Jump Shots ;-) [Was Re: arrays and hashes]

2003-06-04 Thread Tassilo von Parseval
On Tue, Jun 03, 2003 at 08:36:05PM +0200 Kevin Pfeiffer wrote: > Since it seemed like a nice exercise to work on I played with this some > myself. Goals being to try to avoid global variables, use subroutines and > keep MAIN 'uncluttered' and pass arguments to subs as needed. > > I think I did

More Jump Shots ;-) [Was Re: arrays and hashes]

2003-06-04 Thread Kevin Pfeiffer
Since it seemed like a nice exercise to work on I played with this some myself. Goals being to try to avoid global variables, use subroutines and keep MAIN 'uncluttered' and pass arguments to subs as needed. I think I did okay (holding breath), but I'm wondering about things like: my @sorted_ke

Re: arrays and hashes

2003-06-04 Thread Stuart White
This is good explanation. Thanks. > Hi Stuart, > > This is so useful and easy that it's worth really > understanding. Here's a > non-programming metaphor: > > As each player makes a shot he calls out his name > ($1): "smith". The > scorekeeper says, "ah, smith ($score{smith}) - let's > add 1

Re: arrays and hashes

2003-06-04 Thread James Edward Gray II
On Monday, June 2, 2003, at 10:06 PM, Stuart White wrote: This does make it clearer, but not entirely. Is this what is happening: the loop starts, and goes immediately into the if statement. when the regex finds a line with "Jump Shot" it stores that in $2, and the player name in $1. Yes, this

Re: arrays and hashes

2003-06-03 Thread James Edward Gray II
On Monday, June 2, 2003, at 08:10 PM, Stuart White wrote: Ok, I think I get it. the $_ is printing the player name, (though I don't know why I'm not using $1 instead for that) $1 contains the first capture of the last match we did. When you're using match variables like that, store them somewh

Re: arrays and hashes

2003-06-03 Thread Janek Schleicher
John W. Krahn wrote at Mon, 02 Jun 2003 14:44:41 -0700: > You should probably use an array to keep the correct order and a hash to > keep the count: Or to use Tie::IxHash. Greetings, Janek -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: arrays and hashes

2003-06-03 Thread Kevin Pfeiffer
In article <[EMAIL PROTECTED]>, Stuart White wrote: > This does make it clearer, but not entirely. Is this > James wrote: >> This is a common Perl technique, often used with a >> hash named '%seen' >> because that's exactly what it's keeping track of. >> $1 is where you >> were capturing your n

Re: arrays and hashes

2003-06-03 Thread Stuart White
This does make it clearer, but not entirely. Is this what is happening: the loop starts, and goes immediately into the if statement. when the regex finds a line with "Jump Shot" it stores that in $2, and the player name in $1. The next thing it does, and I'm not quite sure how, is it populates a

Re: arrays and hashes

2003-06-03 Thread Stuart White
Ok, I think I get it. the $_ is printing the player name, (though I don't know why I'm not using $1 instead for that) and the $linehash{$_} means, in English, "the value of the key stored in $_" is that right? Thanks for all your help. --- James Edward Gray II <[EMAIL PROTECTED]> wrote: > Print

Re: arrays and hashes

2003-06-03 Thread James Edward Gray II
Print it like this, it's easier: print "$_ : $linehash{$_}\n" foreach (sort keys %linehash); James On Monday, June 2, 2003, at 07:03 PM, Stuart White wrote: One more thing, if I want to sort the hash alphabetically by key where do I put the sort function? I tried it before the while loop that

Re: arrays and hashes

2003-06-03 Thread James Edward Gray II
On Monday, June 2, 2003, at 06:54 PM, Stuart White wrote: I don't understand this syntax: $linehash{$1}++; Could you explain it to me? Absolutely. This is a common Perl technique, often used with a hash named '%seen' because that's exactly what it's keeping track of. $1 is where you were ca

Re: arrays and hashes

2003-06-03 Thread Stuart White
One more thing, if I want to sort the hash alphabetically by key where do I put the sort function? I tried it before the while loop that does the printing and on the each function (sort(each(%linehash))) and that just gave me numbers first, colon, player names. and I figure that it wouldn't work

Re: arrays and hashes

2003-06-03 Thread Stuart White
Hey, thanks that worked! --- James Edward Gray II <[EMAIL PROTECTED]> wrote: > I don't seen any reason to use the array at all, so > I've removed it. > If you had one that I just didn't know about, send > it on back. That's how I tried to solve this piecewise, I thought an array was necessary,

Re: arrays and hashes

2003-06-03 Thread Stuart White
Hey, thanks that worked! --- James Edward Gray II <[EMAIL PROTECTED]> wrote: > I don't seen any reason to use the array at all, so > I've removed it. > If you had one that I just didn't know about, send > it on back. That's how I tried to solve this piecewise, I thought an array was necessary,

Re: arrays and hashes

2003-06-03 Thread James Edward Gray II
On Monday, June 2, 2003, at 05:12 PM, Stuart White wrote: Hmm, this might actually be more productive I showed less abstract example lines. Not sure I understand perfectly yet, but I'll give it another go. I don't seen any reason to use the array at all, so I've removed it. If you had one that

Re: arrays and hashes

2003-06-03 Thread Stuart White
> You should probably use an array to keep the correct > order and a hash to > keep the count: > I don't really understand what you mean. __ Do you Yahoo!? Yahoo! Calendar - Free online calendar with sync to Outlook(TM). http://calendar.yahoo.com -- To unsubscr

Re: arrays and hashes

2003-06-03 Thread Stuart White
> > m> cc: > > > > Subj

Re: arrays and hashes

2003-06-03 Thread royce . wells
<[EMAIL PROTECTED]To: [EMAIL PROTECTED] m> cc:

Re: arrays and hashes

2003-06-03 Thread Stuart White
Hmm, this might actually be more productive I showed less abstract example lines. (I couldn't do this before as I didn't have the code in front of me.) Here is an example of the lines that my code is selecting and then extracting a player name and jump shot attempt(working on this part) then putti

Re: arrays and hashes

2003-06-03 Thread John W. Krahn
Stuart White wrote: > > I am reading in a file of one line sentences, and then > selecting to store several sentences into an array > based upon the presence of some key words. I then > want to assign the array to a hash. The output of the > array will look something like this: > > Player1: 1 >

Re: arrays and hashes

2003-06-03 Thread James Edward Gray II
On Monday, June 2, 2003, at 04:02 PM, Stuart White wrote: Also, to get the numbers to the right of the colon, I'd have to have a count for each occurrence of each player, how might I do that? Perhaps with something like: my %hash; $hash{ (split /:/, $_)[0] }++ foreach (@array); That just walks t

Re: arrays and hashes

2001-10-01 Thread Bradford Ritchie
Hi Jim, I'm not entirely clear on what you have in the first array, but it sounds like it won't be of much use since you already have a hash with all the information you need. You're probably going to have to create a new data structure that keys off of the date so you can search/sort based on t

Re: arrays and hashes

2001-10-01 Thread Michael Fowler
On Sat, Sep 29, 2001 at 11:08:11AM -0400, Darfler, Jim (J.E.) wrote: > How would I go about sending to a file the volume names and dates sorted > by the date? Open the file, iterate through your data structure, write what data you want to the file, close the file. > I had thought to put the inf