Tcp/ip programming

I am looking for some help with writing a small script that will scan a range if subnets and count the number of reply.
If anyone has any shell programming experience with either perl or tcp/ip could you please give me a hand..

Have you developed a flow chart of logic diagram of exactly what you hope to accomplish? I highly recommend this before actually considering coding.