I am trying to put the csh variable into a perl.
In the below case, i am trying to put the csh variable "var" into my perl code. I tried to use '"$var"' but i don;t think it works.
Can anybody help me pls?
#!/bin/csh
set var = `echo "xxx"`
perl myperlcode.pl file
where the perl code is
#!/usr/local/bin/perl
$[ = 1; # set array base to 1
$, = ' '; # set output field separator
$\ = "\n"; # set output record separator
line: while (<>) {
chomp; # strip record separator
@Fld = split(' ', $_, 9999);
if ($Fld[1] eq '**' && $Fld[8] eq '2007' && $Fld[2] =~ /'"$var"'/) {
print $_;
}
First make sure your 'var' shell variable can be passed to Perl. If "print $ENV{'var'}" in Perl doesn't print anything, you can stop playing with the Perl side because you shell simply cannot export var to the Perl process.