Hi poj,
I had consideration of that, but I do not think that is the issue. As I am able to use your script to get some of services status, I put the services name into my $inputfile, the service status I got is still like '' if I leave the first element of array as '', otherwise it would be the first element of this array @state_name.
btw, I also tried somewhere I have full control, I had the same result.