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
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
>
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
>
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
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
"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.
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
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.
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
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
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
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
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
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
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
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
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
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
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]
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
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
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
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
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
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
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,
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,
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
> 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
>
> m> cc:
>
>
>
> Subj
<[EMAIL PROTECTED]To: [EMAIL PROTECTED]
m> cc:
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
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
>
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
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
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
36 matches
Mail list logo