Try to follow these steps:
- find the process pid of the shell, you may use a command like:
ps -ef | grep <your_script_name>
You might find one or more (if for example it's stuck in a pipelined series of commands). Repeat this command couple of times. If it doesn't change this means the script is stuck in certain command. In this case, you may attach trace command to the running child process:
sudo strace -p $PID
This will show you what is being executed, either indefinite loop (like reading from a pipe), or waiting on some event that never happens.
In case you find
ps --ppid $PID changes, this indicates that your script is advancing but it's stuck somewhere, e.g. local loop in the script. From the changing commands, it can give you a hint where in the script it's looping.
Finally, a very simple method to debug a perl is to use perl debugger:
perl -d script.pl
More: 1, 2, 3, 4, 5