First rule of fixing broken perl code. Apply 'use strict;' and 'use warnings;'. This gives a lot of warnings and errors with your code, which would warrant sorting first.
It looks like you're doing a fairly substantial number of slightly horrible things. I would imagine that if you did use strict and warnings, your problem would vanish (or become obvious. For starters - populating an array by setting $n.
my @jobvar_list = ( "senior", "exec" );
Will do exactly the same thing. Even better, you could use a hash, so you never needed to iterate through one list, and reference another list.
my %jobvar_list = ( 'senior' => 'Senior', 'exec' => 'Exec' ); my $quick_jobtype = "exec"; foreach my $temp_jobvar ( keys %jobvar_list ) { print "$temp_jobvar, $jobvar_list{$temp_jobvar}\n"; if ( $temp_jobvar eq $quick_jobtype ) { print "$temp_jobvar matches $quick_jobtype"; my $sortby = " WHERE jobtype like '%$jobvar%' and active='yes' AND + jobstatus!='suspend' ORDER BY dateadded DESC, jobtitle ASC"; print $sortby; } }
I think it must be that 'if' clause that's causing you problems - what is it trying to do? It sounds like it's evaluating but never working, and therefore not running that 'sortby' and 'Build_Lists_Both' segments of code. Which is odd, because it seems to be doing so in that sample code you posted. Is there any chance that you've tidied your code up a bit, with the job title list? that 'eq' line means that the two variables have to match precisely - no whitespace or linefeeds. Because your code _does_ run as is.
In reply to Re: Help with a loop
by Preceptor
in thread Help with a loop
by htmanning
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |