> First Problem.
> 
> The two tables are not the same length however my first if statements
> will end the process after it reaches the end of the table. My second
> and third if's will find the output of the first difference and then
> stop. What I need to know is what type of for loop do I need 
> to continue
> this program on to the next instances.
> 
> The for loops I have now merely prints out a number 3 instead of the
> username lists. My questions is am I on the right track here? If not
> does anyone have any better suggestions?
> 
> Thank-You,
> 
> ---------------------------------------- Program Below
> ---------------------------
> 
> #!/usr/local/bin/perl 
> 
> use Sybase::DBlib;
> use DBI;
> 
> # ClienTele Sybase Information
> 
> Database & User Name Information Omitted
> 
> $i = 0;
> $j = 0;
> 
> $ctelnew = new Sybase::DBlib $sql_user,$sql_password,$sql_server;
> $ctelnew->dbuse ('clientele');
> $ctelnew->dbcmd("select EmailName from EmailAccount where 
> AccountNumber
> = '012616' "); $ctelnew->dbsqlexec; while ($ctelnew->dbresults !=
> NO_MORE_RESULTS) {
>   while(@dat = $ctelnew->dbnextrow) {
>     push @emailname,$dat[0];
>   }
> }

Ok so this gets a bunch of email addresses and puts them into @emailname

> $dbh = DBI->connect("DBI:mysql:database=$dbase;$dbhost", 
> $dbuser,$dbpw);
> $sth = $dbh->prepare("select address from notify_list"); $sth->execute
> || print "Can't execute statement: $DBI::errstr\n"; while (@sub =
> $sth->fetchrow_array) {
>   $subname = $sub[0];
>   ($user,$ext) = split(/@/, $subname);
>   push @sub_name,$user;
> }
> close(SUB);

And this gets a bunch of something-elses and puts them into @sub_name

> while ($i <= $#emailname && $j <= $#sub_name) {
>   if ($emailname[$i] eq $sub_name[$j]) {
>     $i++;
>     $j++;
>   } elsif ($emailname[$i] lt $sub_name[$j]) {
>     foreach ($i=$i;$i <= $#emailname;$i++) {
>       print "$i\n";
>     }
>     $i++;
>   } else {
>     foreach ($j=$j;$j <= $#sub_name;$j++) {
>       print "$j\n";
>     }
>     $j++;
>   }
> }

So by the time you get to the while loop, you have two arrays that
aren't the same size and you want to do what with them?

You can change your for loop syntax to this:

foreach($i..$#emailname) {
  # do stuff
}

Instead of the c-style for loops.

Hope that helps,

 -dave



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to