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.