I think there are two questions you should ask yourself:
- Does $ApID contain what you think it does? and
- Is the shell script actually receiving the value Perl is trying to send it?
The first is easy enough: insert print "\$ApID='$ApID'\n" before you spawn the command. This assumes $ApID contains all printable characters. If not, you may need to enlist the aid of Data::Dumper, Data::Dump, YAML, JSON, or whatever your favorite dumper/serializer is.
The second is harder, because it may not be obvious what the shell is doing with what you have given it. If you can modify $path/CA.sh, have it echo $ApID and see what you get.