You're absolutely right. Its better to use one sorted array instead of
sorting it all the time.

Thanx much again

Dan 

-----Original Message-----
From: Michael A Chase [mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 09, 2003 11:30 AM
To: Rozengurtel, Daniel; dbi-users
Subject: Re: bind columns behavior


On Tue, 9 Sep 2003 09:43:18 -0400  "Rozengurtel, Daniel"
<[EMAIL PROTECTED]> wrote:

> Thanx much for a nice example it definitely worked for me. However I
> also succeeded (by gish and by gosh I guess) to achieve what I needed
> in this following way:
> # print header record

Memory is cheap enough that you only need to sort once, then use the
array that contains the sorted list.

#> if ($sort_flg eq "Y")
#>   {print OUTFILE join('|',sort @ClnFldsArray)."\n"; }
#> else
#>   {print OUTFILE join('|',@ClnFldsArray)."\n"; }

   my @OutFldsArray = @ClnFldsArray;
   @OutFldsArray = sort @ClnFldsArray if $sort_flg eq "Y";
   print OUTFILE join( "|", @OutFldsArray ), "\n";

> 
> my %row;
> my    $sth = $dbh->prepare_cached($sql) || die $dbh->errstr;
>       $sth->execute;
>       $sth->bind_columns( \( @[EMAIL PROTECTED] ));
> while($sth->fetch) {
#>  if ($sort_flg eq "Y")
#>    { print OUTFILE map("$row{$_}|", sort @ClnFldsArray), "\n"; }
#>  else
#>    { print OUTFILE map("$row{$_}|", @ClnFldsArray), "\n"; }

    # The method above leaves a trailing "|" on each line
    print OUTFILE join( "|", @[EMAIL PROTECTED] ), "\n";

> }#while
> 
> 
> Using hash, was useful to me, since I was able to get into any HASH
> element looping thru sorted/not sorted array of predefined fields.
> Something that I was not able to achieve when I started this email.
> I am still puzzled as to why it worked!!!

You may want to look at the following PODs.  You can view them from
http://search.cpan.org/dist/perl/ or by running perldoc $(name).

perlop
perlreftut
perlref
perlfunc
perlfaq

-- 
Mac :})
** I usually forward private questions to the appropriate mail list. **
Ask Smarter: http://www.catb.org/~esr/faqs/smart-questions.html
Give a hobbit a fish and he eats fish for a day.
Give a hobbit a ring and he eats fish for an age.


____________________________________________________________________

IMPORTANT NOTICES: 
          This message is intended only for the addressee. Please notify the
sender by e-mail if you are not the intended recipient. If you are not the
intended recipient, you may not copy, disclose, or distribute this message
or its contents to any other person and any such actions may be unlawful.
 
         Banc of America Securities LLC("BAS") does not accept time
sensitive, action-oriented messages or transaction orders, including orders
to purchase or sell securities, via e-mail.

         BAS reserves the right to monitor and review the content of all
messages sent to or from this e-mail address. Messages sent to or from this
e-mail address may be stored on the BAS e-mail system.
__________________________________________________________________

Reply via email to