I am trying to count the no. of blanks that appear and then break out of the loop when all arrays' last elements are blanks/spaces. I think sprintf will do it but I can't figure it out:
printf DGSUM" +--------------------------------------------------------+\n"; for $sr(1 ..9) { $one = ""; if($place1[$sr] eq ""){ printf DGSUM " | %d | N/A |",$sr; $one = "mt"; }else{ printf DGSUM " | %d | %9s | ",$sr, $cwdp[$sr]; } if($place2[$sr] ne ""){ if($one eq "mt"){ printf DGSUM " %9s |", $place2[$sr]; }else{ printf DGSUM " %9s |", $place2[$sr]; #data in so print to screen } }else{ printf DGSUM " N/A |"; } if($place3[$sr] eq ""){ $one = "mt"; printf DGSUM " N/A |"; }else{ printf DGSUM " %9s |", $place3[$sr]; } if($place4[$sr] ne "" ){ printf DGSUM " %9s |\n",$place4[$sr]; }else{ if($one ne "mt"){ printf DGSUM " %9s |\n", $place4[$sr]; }else{ printf DGSUM " N/A |\n"; #printf DGSUM "place4=%s\n",$place4[$sr++]; } #printf DGSUM "place4=%s\n",$place4[$sr++]; #if (($place1[$sr++] eq "") && ($place2[$sr++] eq "") && ($place3[$sr++] eq "") && ($place4[$sr++] eq "")){ #break;} } each $place1[$sr] , $place2[$sr] , $place3[$sr], $place4[$sr] is a dial-in gateway. I go through each gateway, pluck out its call stats and print them out. If there's no gateway, I print N/A (that is there are 3 gw's per site except for the last one that has 5 gw's, therefore the other 3 gateway's for their row 4 +5 have N/A beside them here's the output: +--------------------------------------------------------+ | Daily Dial Gateway Call Totals | | for 14 11 2001 | +--------------------------------------------------------+ +--------------------------------------------------------+ | DG # | Place1 | Place2 | Place3 | Place4 | +--------------------------------------------------------+ | 1 | 83018 | 66848 | 87005 | 62313 | | 2 | 76762 | 66734 | 87000 | 62260 | | 3 | 59572 | 57035 | 74555 | 53402 | | 4 | N/A | N/A | N/A | 0 | | 5 | N/A | N/A | N/A | 0 | | 6 | N/A | N/A | N/A | N/A | +--------------------------------------------------------+ |Total | 219352 | 190617 | 248560 | 177975 | +--------------------------------------------------------+ +--------------------------------------------------------+ | Grand Total | 836504 | +--------------------------------------------------------+ I am trying to prevent the last row of N/A from appearing as there is no gateway 6 therefore the rows should stop at row 5 and row 6 should not appear. I have been at this for a while and can't work out how to do this with sprintf any ideas ? thanks in advance Harry -- _______________________________________________ Sign-up for your own FREE Personalized E-mail at Mail.com http://www.mail.com/?sr=signup 1 cent a minute calls anywhere in the U.S.! http://www.getpennytalk.com/cgi-bin/adforward.cgi?p_key=RG9853KJ&url=http://www.getpennytalk.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]