Re: comparing a string to elements of an array

2004-03-08 Thread R. Joseph Newton
Stuart White wrote: > > > In the end, I want @SAN to have all the unique > > names > > > within the file. Any ideas? > > You just described a Hash. Use %hash and then > > either uppercase or lowercase the the incoming key. > > YOu could then add a count to the Hash so you know > > you are l

Re: comparing a string to elements of an array

2004-03-08 Thread Stuart White
This worked perfectly! Thanks. --- James Edward Gray II <[EMAIL PROTECTED]> wrote: > On Mar 8, 2004, at 4:19 PM, Stuart White wrote: > > > Conceptually, what you say the result is, is what > I > > want, thanks. When I read it though, without the > > comment, I'd guess that the program would pa

Re: comparing a string to elements of an array

2004-03-08 Thread Stuart White
> If you want the teams and players to be unique you > should probably use a > hash of hashes (HoH): > Eventually, I think I'll use that, but not yet. Baby steps. :) thanks. > my %stats; > while ( ) { > my ( $t, $p ) = /\[($team)\] ($player)/ or next; > $stats{ $t }{ $p } = (); > >

Re: comparing a string to elements of an array

2004-03-08 Thread Stuart White
> This is where the work gets done, yes. In English > it reads, for every > word in the array, add one to the corresponding hash > value under that > key. That will give you a hash with keys for all > the words. Their > values will be the number of times that word > appeared in the array. >

Re: comparing a string to elements of an array

2004-03-08 Thread John W. Krahn
Stuart White wrote: > > I'm reading in lines of text, and extracting the > relevant parts of it. These relevant parts are then > being pushed onto an array. My trouble is that these > parts are a maximum of 24 unique names. However, when > pushed onto the array, there is no mechanism for > comp

Re: comparing a string to elements of an array

2004-03-08 Thread James Edward Gray II
On Mar 8, 2004, at 4:19 PM, Stuart White wrote: Conceptually, what you say the result is, is what I want, thanks. When I read it though, without the comment, I'd guess that the program would pair those words like so: dog:cat, dog:lizard, dog:wombat with dog:lizard overwriting dog:cat, and dog:wom

Re: comparing a string to elements of an array

2004-03-08 Thread Stuart White
--- James Edward Gray II <[EMAIL PROTECTED]> wrote: > On Mar 8, 2004, at 1:24 PM, Stuart White wrote: > > > If I had a hash, I'd have to have a key and a > value > > though. I'm just looking for one or the other. I > > suppose I could have key value pairs in the %SAN > hash > > like so: > > Pe

RE: comparing a string to elements of an array

2004-03-08 Thread Stuart White
--- "Wagner, David --- Senior Programmer Analyst --- WGO" <[EMAIL PROTECTED]> wrote: > Stuart White wrote: > >>> In the end, I want @SAN to have all the unique > names > >>> within the file. Any ideas? > >>You just described a Hash. Use %hash and then > >> either uppercase or lowercase the th

Re: comparing a string to elements of an array

2004-03-08 Thread James Edward Gray II
On Mar 8, 2004, at 1:37 PM, James Edward Gray II wrote: my @words = qw(dog cat dog lizard dog wombat dog); my %seen; foreach (@words) { $seen{$_}++; } my @words = keys %seen; Egad, I'm dumb today, drop the my in the above line. Sorry. print "@words\n"; # only prints one dog James -- To

Re: comparing a string to elements of an array

2004-03-08 Thread James Edward Gray II
On Mar 8, 2004, at 1:24 PM, Stuart White wrote: If I had a hash, I'd have to have a key and a value though. I'm just looking for one or the other. I suppose I could have key value pairs in the %SAN hash like so: Perl hashes are pretty versatile. As Wags was saying, just stick each item in the

RE: comparing a string to elements of an array

2004-03-08 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Stuart White wrote: >>> In the end, I want @SAN to have all the unique names >>> within the file. Any ideas? >> You just described a Hash. Use %hash and then >> either uppercase or lowercase the the incoming key. >> YOu could then add a count to the Hash so you know >> you are looking at all

RE: comparing a string to elements of an array

2004-03-08 Thread Stuart White
> > In the end, I want @SAN to have all the unique > names > > within the file. Any ideas? > You just described a Hash. Use %hash and then > either uppercase or lowercase the the incoming key. > YOu could then add a count to the Hash so you know > you are looking at all things or not. The k

RE: comparing a string to elements of an array

2004-03-08 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Stuart White wrote: > I'm reading in lines of text, and extracting the > relevant parts of it. These relevant parts are then > being pushed onto an array. My trouble is that these > parts are a maximum of 24 unique names. However, when > pushed onto the array, there is no mechanism for > compari