Hello pd,
There are two ways to enable both the shell script and a perl script (they really works for any other kind of programming language with minimal support).
[1] write down the value of the variable into a file (vars.txt, for example) and then open the file with the shell script and read the data (var's value) and do something with it.
[2] if you do know how to use the sockets functionality for C and perl you can exchange data between this to languages through a socket connection (like if they were tied with a pipe) that allows you to send/received data on every separate program.
if you do not know how to do any of this two alternatives, let me know and i can guide you to the corresponding books or links to make it happen.