Re: Returning multiple MySQL rows from module



Tom Phoenix wrote:
On 11/27/07, Steve Bertrand <iaccounts@xxxxxxxxxx> wrote:

The current setup feels very 'kludgy' to me. The code snip below comes
out of the module. I hope there is enough context to see why I think it
can be improved.

Actually, the snippet you submitted seems pretty straightforward. It
could be improved (what code couldn't?) but it's not in *need* of
improvement, IMHO: It can't become impressively faster or clearer.
What seems kludgy about it? What improvement are you seeking?

Well, I didn't like the fact I was returning an AoA. I have subsequently
changed the code to only allow a single row return, and assign it
directly to $self via a hashref instead:


-- snip --

while (my $service_info = $query->fetchrow_hashref) {

for my $field (keys %$service_info) {
$self->{$field} = $service_info->{$field};
}
}

-- end snip --

Thanks for your response Tom!

Steve
.



Relevant Pages

  • Re: MOA, Restricted and probhibited and warning areas
    ... out of the AIM was but a small snippet, out of context, pertained only to ... IFR, and is inapplicable to student pilots and you are trying to deflect ...
    (rec.aviation.student)
  • Re: if(wantarray){...}else{...}
    ... > I have "return" snippets like this in several funktions ... > sub fun1 { ... > # Start return snippet ... Context is "see through". ...
    (comp.lang.perl.misc)
  • Re: Returning multiple MySQL rows from module
    ... I hope there is enough context to see why I think it ... the snippet you submitted seems pretty straightforward. ... --Tom Phoenix ... Stonehenge Perl Training ...
    (perl.beginners)
  • Re: Is this "racist?"
    ... and permanent. ... Another snippet taken out of context to stir controversy. ...
    (alt.guitar.amps)