ping loop

i need to write a script that can loop through ej.192.162.0.0 to 192.162.0.256
find the ones that are connected and the ones not connected
write the name , ip address and connection status of each one in a file
to later use it in perl to create a web page with the information
thanks guys

#!/bin/bash
for i in `sec 0 255`; do 
    ping -c 1 $i >/dev/null 2>&1 
    if [ "$?" = "0" ]; then 
echo -n "up" 
else echo -n "down" 
    fi
done

Something like that, that's the logic.
EDIT : Actually, there is written one