โปรแกรมจะทำการเช็คว่า มี char ในตัวแปร $taget หรือไม่ถ้ามีก็จะแสดงผล แล้วก็จำทำการค้นหาต่อไป
หลังจากนั้นก็จะแสดงผลจำนวนที่พบทั้งหมด

[src] @test=('a','b','c','c');
$size=@test;
$i=0;
$found=0;
$target='c';

while($size>$i){

if(@test[$i] eq $target ){

if($count == 0) {print "foundn";}

$found=1;
$count++;
}

$i++;
}
print "$target occur: $count";
if($found=0){print "Not found";}

[/src]