Learning Perl and Stuff was .... Re: Difference of $hash, and %hash. (was Getting my head round hashes)

2003-06-06 Thread drieux
On Friday, Jun 6, 2003, at 10:04 US/Pacific, Greenhalgh David wrote: p0: I must confess myself to be a 'perl purist'[1] in the sense that my stained copy of the first edition of perl is as trashed as my copy of Sed and Awk. So I come to the discussion having asked, "I want to cut over to perl5 f

Re: Difference of $hash, and %hash. (was Getting my head round hashes)

2003-06-06 Thread Randal L. Schwartz
> "Scot" == Scot Robnett <[EMAIL PROTECTED]> writes: Scot> Word of caution: I tried getting help on IRC (irc.debian.org) Scot> and found the Perl community there to be much less helpful and Scot> much more arrogant (if any of you are on this list, I'm Scot> definitely generalizing, so please t

RE: Difference of $hash, and %hash. (was Getting my head round hashes)

2003-06-06 Thread Kristofer Hoch
> basic to the experienced community. I find this list > to be helpful, too. > Word of caution: I tried getting help on IRC > (irc.debian.org) and found the > Perl community there to be much less helpful and > much more arrogant (if any > of you are on this list, I'm definitely > generalizing, so

RE: Difference of $hash, and %hash. (was Getting my head round hashes)

2003-06-06 Thread Scot Robnett
e, even if you -have- RTFM. :-) -Original Message- From: Greenhalgh David [mailto:[EMAIL PROTECTED] Sent: Friday, June 06, 2003 12:05 PM To: drieux Cc: cgi cgi-list Subject: Re: Difference of $hash, and %hash. (was Getting my head round hashes) On Thursday, June 5, 2003, at 11:20 pm, drieux wrot

Re: Difference of $hash, and %hash. (was Getting my head round hashes)

2003-06-06 Thread Andrew Brosnan
On 6/6/03 at 6:04 PM, [EMAIL PROTECTED] (Greenhalgh David) wrote: > > On Thursday, June 5, 2003, at 11:20 pm, drieux wrote: > > > > > On Thursday, Jun 5, 2003, at 14:33 US/Pacific, Greenhalgh David wrote: > > [..] > >> My thanks to both of you. The explanation was clear even to me, > >> much be

Re: Difference of $hash, and %hash. (was Getting my head round hashes)

2003-06-06 Thread Greenhalgh David
On Thursday, June 5, 2003, at 11:20 pm, drieux wrote: On Thursday, Jun 5, 2003, at 14:33 US/Pacific, Greenhalgh David wrote: [..] My thanks to both of you. The explanation was clear even to me, much better than the book i am using to learn perl. [..] which book are you trying to learn from? Se

Re: Difference of $hash, and %hash. (was Getting my head round hashes)

2003-06-06 Thread drieux
On Thursday, Jun 5, 2003, at 14:33 US/Pacific, Greenhalgh David wrote: [..] My thanks to both of you. The explanation was clear even to me, much better than the book i am using to learn perl. [..] which book are you trying to learn from? What you may also want to think about, is that an author of

Re: Getting my head round hashes

2003-06-06 Thread drieux
On Thursday, Jun 5, 2003, at 21:43 US/Pacific, Mark Young wrote: [..] One nice way to learn about hashes, arrays, scalars and references, is to learn the perl debugger and just experiment. There is a perl debugger tutorial in the perl documentation. [..] My Compliments! cf perldoc p

Re: Difference of $hash, and %hash. (was Getting my head round hashes)

2003-06-06 Thread Greenhalgh David
On Thursday, June 5, 2003, at 09:46 pm, drieux wrote: On Thursday, Jun 5, 2003, at 13:34 US/Pacific, Kristofer Hoch wrote: [..] This is possibly the best answer. I won't give any other. [..] why thank you. there are basically two reasons that one should be playing with 'just perl stuff' -

Re: Difference of $hash, and %hash. (was Getting my head round hashes)

2003-06-06 Thread drieux
On Thursday, Jun 5, 2003, at 13:34 US/Pacific, Kristofer Hoch wrote: [..] This is possibly the best answer. I won't give any other. [..] why thank you. there are basically two reasons that one should be playing with 'just perl stuff' - a. they have hashes well done, so if you NEED

Re: Difference of $hash, and %hash. (was Getting my head round hashes)

2003-06-06 Thread Kristofer Hoch
This is possibly the best answer. I won't give any other. --- drieux <[EMAIL PROTECTED]> wrote: > > On Thursday, Jun 5, 2003, at 13:07 US/Pacific, > Andrew Brosnan wrote: > [..] > my $hash = {}; > > while (my $rows = $response->fetchrow_hashref){ > $hash->{$rows->{task_ID}}

Re: Difference of $hash, and %hash. (was Getting my head round hashes)

2003-06-06 Thread drieux
On Thursday, Jun 5, 2003, at 13:07 US/Pacific, Andrew Brosnan wrote: [..] my $hash = {}; while (my $rows = $response->fetchrow_hashref){ $hash->{$rows->{task_ID}} = $rows; } Why is hash declared as my $hash and not my %hash? and how does the This creates an annonymous hash '{}' and stores a refe

Re: Difference of $hash, and %hash. (was Getting my head round hashes)

2003-06-06 Thread Andrew Brosnan
> > > > > my $hash = {}; > > > > > > while (my $rows = $response->fetchrow_hashref){ > > > $hash->{$rows->{task_ID}} = $rows; > > > } > > > > Why is hash declared as my $hash and not my %hash? > > and how does the > > This creates an annonymous hash '{}' and stores a reference to that

Re: Difference of $hash, and %hash. (was Getting my head round hashes)

2003-06-06 Thread Kristofer Hoch
David, I will look it up to be accurate. Give me a bit of time. Kristofer --- Greenhalgh David <[EMAIL PROTECTED]> wrote: > Kristofer, > > Thank you. > > It was a big mistake to forget the method. > > I think I still have problems with catching when to > use $ or %. I don't > fully understa

Re: Getting my head round hashes

2003-06-06 Thread Greenhalgh David
Thanks Scott, So %hashref now has the modified list of priorities with the task_ID as the key. I think I'm beginning to get the hang of this... I do have use DBI in the code (clipped it by accident when I extracted the segment) but you are quite right about me missing the the fetchrow_hashref

RE: Getting my head round hashes

2003-06-06 Thread Scot Robnett
Sorry, forgot to comment something...yeeesh #!/usr/local/perl -wT use strict; use CGI; use DBI; # need this! my $marker = 5; # (or whatever number) my $dbh=DBI->connect(DBI:mysql:database:localhost,"user","password"); my $sth=$dbh->prepare("SELECT task_ID, priority FROM task_list WHERE priority >

RE: Getting my head round hashes

2003-06-06 Thread Scot Robnett
You're not pulling in the DBI functions, for one thing. Short example of using the hashref function built into DBI is shown below. #!/usr/local/perl -wT use strict; use CGI; use DBI; # need this! my $marker = 5; (or whatever number) my $dbh=DBI->connect(DBI:mysql:database:localhost,"user","passwo

Re: Getting my head round hashes

2003-06-06 Thread Greenhalgh David
Kristofer, Thank you. It was a big mistake to forget the method. I think I still have problems with catching when to use $ or %. I don't fully understand this section of the code: my $hash = {}; while (my $rows = $response->fetchrow_hashref){ $hash->{$rows->{task_ID}} = $rows; } W

Re: Getting my head round hashes

2003-06-06 Thread Kristofer Hoch
David, You don't have a response set at execute. You have a reference to a responce set. You need to use DBI methods to access the results. Try this... $response->execute(); my $hash = {}; while (my $rows = $response->fetchrow_hashref){ $hash->{$rows-

Getting my head round hashes

2003-06-06 Thread Greenhalgh David
Hi all, I have a script which mostly works, but when I get to the part with hashes, it stops. I'm obviously doing something very basically wrong, but I can't see what. (been staring at so long it could be anything.) A segment of the code is below: #!/usr/local/perl -wT use strict; use CGI; # D

RE: Getting my head round hashes

2003-06-05 Thread Mark Young
experimentation very easy and interesting. Mark >> -Original Message- >> From: Greenhalgh David [mailto:[EMAIL PROTECTED] >> Sent: Thursday, June 05, 2003 1:16 PM >> To: [EMAIL PROTECTED] >> Subject: Getting my head round hashes >> >> Hi all, >> &