sub getSND(){ $sql = < b.type_name and trans_date between '010501' and '010530' END_SQL $query = &execsql($sql); if(!$print_only){ $~ = PB_TOP_SNDIDONLY; write; while (@data = $query->fetchrow) { $~ = PB_BODY_SNDIDONLY; write; } }else{ open(PB_BODY_SNDIDONLY, "> tmp/SND.DOC") or die "Can't $!\n"; #Lock File flock(PB_BODY_SNDIDONLY, 2); $~ = PB_TOP_SNDIDONLY; write PB_TOP_SNDIDONLY; $~ = PB_BODY_SNDIDONLY; write PB_BODY_SNDIDONLY while( @data = $query->fetchrow ); #Unlock file flock(PB_BODY_SNDIDONLY, 8); close (PB_BODY_SNDIDONLY); } }