in reply to argument to delete function

I want to know whether we can write subroutines which can detect the scalar and array element and how?

No, all a sub receives is scalars.

delete is handled specially by the parser.

delete($a[0]);
is compiled into something like
delete(\@a, 0);

What are you actually trying to do?