in reply to counting syn+ack. Help!!!

It seems syn_packets is only called for syn packets (as the name implies), so you probably won't be counting ack packets without changing the filter expression. That should be the same number normally but bugs, network problems or malice might make them differ)

Now what is your problem with counting? It seems this is already done with '$count++'. The only thing missing seems to be the reporting (the print after the loop call won't be executed if the capture loop is endless). Either write to a log file or print a report every 100 or 1000 packets or after some time has elapsed (this can be done in the syn_packets subroutine). The time in seconds you get with time(). Put the starting time in some variable and subtract the actual time from that to know how much time elapsed. Or check how to end the Net::Pcap::loop (check the documentation) so that the print afterwards really gets executed