http://www.perlmonks.org?node_id=999454


in reply to CSH script that calls a perl script

There are many ways to return data from your perl script to your csh script.

If the perl script is not otherwise writing to STDOUT, you could output the new value to STDOUT. Your csh script could execute the perl script and capture its STDOUT and use what it receives to update its variable.

You could have the perl script write a file with the new value in it and have your csh script read the file after it runs the script. If you might have more than one instance of the csh and perl script running at a time, you will have to make sure the filenames are unique. The easiest way might be to generate a unique filename in the csh script (e.g. use the pid in the filename) and pass the filename to the perl script, as you do stapl and serial.

There are other options for IPC, including named and unnamed pipes and sockets, but these would be a bit more complicated to use. I wouldn't bother unless I had already ruled out the simple options.