count the number of bonds around a particular atom

Dear all.

I want to count the number of bonds that exist in a certain radius from a certain atom.

Actually, this can be done by properly using the atom selection function of the visualizer, but I want to use it more conveniently through a script.

But I have short knowledge of perl script.

Does anyone have a script that does this?

My guess is, wouldn't it be possible to specify an atom name for a particular atom and count the bonds that exist around it?

I'd be very grateful if anyone could give me some advice.