Using Perl scripts to select atoms for a given element

Dear Engineers and Users,

I want to use a perl script to remove atoms connected to a specified element. How can I achieve it?