Search code examples
perlcsh

How to call a Perl program from a csh script


I have this simple code to execute, but have failed.

a.csh

#! /bin/csh -f

`perl a.pl`

a.pl

#use perl
    eval 'exec perl -w -S $0 ${1+"$@"}'
    if 0;

use Cwd;

print "here.\n";

When I run a.csh, it reports an error as below.

here: Command not found

I am not sure what that means; any suggestion is welcome.


Solution

  • The backticks in your program are returning the output of the perl script. Then csh tries to execute that output as csh. toolic's comment telling you to remove the backticks is correct: perl a.pl. Reading more about how backticks work might be useful.