Gossamer Forum
Home : General : Perl Programming :

problem with arrays in sub query

Quote Reply
problem with arrays in sub query
Hi all,
using DBman flatfile......
I'm using the "sort by multiple fields" mod sorting on 3 fields (with great success, I should say). But I do have one problem. This mod only works if $values[$in{'sb1'}] contains 1 single value. In my case I have multiple values in this field (db position is 1). I know, I know, but I wanted to try it anyway.....

Now, I figured out to add the following in sub query just after:


open (DB, "<$db_file_name") or &cgierr("error in search. unable to open database: $db_file_name.\nReason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB>) {
(/^#/) and next LINE; # Skip comment Lines.
(/^\s*$/) and next LINE; # Skip blank lines.
$line = $_; chomp ($line); # Remove trailing new line.
@values = &split_decode($line);


# my new code
# $values[1] being the sort field in question
if ($in{'view_select_records'}) {
@tmp_value = split(/\|/, $values[1]); #$values[1] in this case eq "value1|value2|value3" etc.
foreach $tmp_value (@tmp_value) {
$values[1] = $tmp_value;
}
push (@values, $values[1]);
}
# end

this does not interfere with any of my other search routines and prints out the record with multiple field values no problemo, but uses only 1 of the available field values (not necessarily the first one?). In other words, it does not make a "temporary copy" (for want of a better word) of the record (or should I say $line). How can I stack all the newly assigned $values[1] in @values? I need to "push" @values so that I don't have to worry about the rest of sub query or any other subsequent sorting functions. This also lets me call $rec{'fieldname'} as usual.

I know I'm missing something rudimentary....I've tried everything I can think of and I'm not one to give up easily....been on this thing for hours.

Thanks for any help.

Nora
Nora @
www.baytides.ca
Subject Author Views Date
Thread problem with arrays in sub query baytides 5880 Oct 8, 2003, 9:11 AM
Thread Re: (cont.) problem with arrays in sub query
baytides 5739 Oct 8, 2003, 2:09 PM
Thread Re: [baytides] (cont.) category headings and records.
baytides 5730 Oct 11, 2003, 2:42 PM
Thread Re: [baytides] (cont.) category headings and records.
lanerj 5724 Oct 11, 2003, 9:46 PM
Thread Re: [lanerj] (cont.) category headings and records.
baytides 5722 Oct 12, 2003, 12:47 AM
Post Re: Solution, I think:)
baytides 5711 Oct 12, 2003, 6:58 AM