Thanks for the help...  I finally figured that out about 30 minutes
later...  (My message to the list had been sent already, but did not
appear on the list, apparently...  )

Anyways, It's working nicely now...  :)  Thanks...

---------------------------
Jason H. Frisvold
Senior ATM Engineer
Engineering Dept.
Penteledata
CCNA Certified - CSCO10151622
[EMAIL PROTECTED]
---------------------------
"Imagination is more important than knowledge. Knowledge is limited.
Imagination encircles the world." -- Albert Einstein [1879-1955]


-----Original Message-----
From: bob ackerman [mailto:[EMAIL PROTECTED]] 
Sent: Saturday, May 04, 2002 2:04 PM
To: [EMAIL PROTECTED]
Subject: Re: DBI - selectall_arrayref Help!


On Friday, May 3, 2002, at 12:39  PM, Jason Frisvold wrote:

> Let's see if I can explain what I'm trying to do before I toss code
> out...  I have a database with several columns of data.  I want to
fetch
> all the pertinent info into a single array of arrays and then work on
> each row of the data individually.  (I don't want to use fetch()
because
> there's no telling how long it will take to crunch the data)
>
> So, here's some "simple" code to look at this...
>
> This is in a separate .pm file...
>
> sub getdata {
>    my $self = shift;
>    my $value = $_[0];
>
>    # DBHANDLER is defined elsewhere (and is definitely called) ...
It's
> a MySQL database
>    $self->{ARRAYLIST} = $self->{DBHANDLER}->selectall_arrayref("select
> row1, row2, row3 from mydb where somevalue=$value");
>    $self->{ARRAYCOUNTER} = 0;
>    return();
> }
>
> sub loadrow {
>    my $self = shift;
>
>    if ((defined($self->{ARRAYLIST})) and ($self->{ARRAYCOUNTER} <
> scalar(@{$self->{ARRAYLIST}}))) {
>       ($self->{ROW1}, $self->{ROW2}, $self->{ROW3} =
> ${$self->{ARRAYLIST}[$self->{ARRAYCOUNTER}]};
>

i think you want to deref the expression on the right into an array, not
a 
scalar:
@{$self->{ARRAYLIST}[$self->{ARRAYCOUNTER}]}

so you can assign elements of the array to your 3 scalar list on the
left

>       $self->{ARRAYCOUNTER}++; # Increment the counter
>       return(1);  # And return a 1 to indicate success
>    }
>
>    return(0);
> }
>
> And the main program has something along the lines of :
>
> $obj->getdata($somevalue);
> while($obj->loadrow()) {
>    # do stuff with the data rows
> }
>
> My problem is that it appears that $self->{ROW1}, $self->{ROW2}, and
> $self->{ROW3} are not getting any data placed into them.  In fact,
I've
> been getting this error :
>
> Not a SCALAR reference at
> /usr2/local/graphmon/TrendAnalyzer/ClassThreshold.pm line 78.
>
> I'm not sure how to fix this...  Can anyone give me any pointers on
how
> to make this work?
>
> ---------------------------
> Jason H. Frisvold
> Senior ATM Engineer
> Engineering Dept.
> Penteledata
> CCNA Certified - CSCO10151622
> [EMAIL PROTECTED]
> ---------------------------
> "I love deadlines.  I especially like the whooshing sound they make as
> they go flying by." -- Douglas Adams [1952-2001]
>
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to