[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 208
  • Last Modified:

Exitting from while loop

i am using one Xbase module for accessing DBF files.
I am using two dbf files for generating some reports. i want to generate reports based on the first dbf file . but one required field is in second dbf file. so for each record in first dbf file, i am searching that record in second dbf file also. if i found that record in second dbf file , i want to exit from that while loop. for this i given exit command in perl. but it is exiting from the whole perl program.
ie i am getting only one record in the recport. so how to exit from the loop.
$database="first file"
$data1 ="second dbf"
while(!$database->eof)
{
$found=1;
$user = $fields[11];
$data1->go_top;
@dataf=$data1->get_record;
while(!$data1->eof)
{
if ($fields[0] eq $dataf[0])
{
$fg = $dataf[1];
exit ---
}
$data1->go_next;
@dataf = $data1->get_record;
}
print <<endresult;
<CENTER><TABLE WIDTH=678 >
<TR>
<TD><B><FONT FACE="Arial,Helvetica"><FONT COLOR="#660000">User ID            </FONT></FONT></TD>
<TD><B><FONT FACE="Arial,Helvetica"><FONT COLOR="#000099">$fields[11] </FONT></FONT></TD>
endresult
$database->go_next;
@fields = $database->get_record;
}
0
mon1
Asked:
mon1
  • 2
1 Solution
 
shlomoyCommented:
use 'last' instead of 'exit'

0
 
shlomoyCommented:
In Perl the statement 'last' is just like 'break' in C.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now