#!/usr/bin/perl use strict; use warnings; my $pack = 'test.txt'; #fine when using these vars.... my $sanity_code = "blah"; my $tests = "asdfasdf"; open(PACK,">$pack") or die("failed to open file $pack"); print PACK <<_M_E; #!/usr/intel/bin/tcsh -f $sanity_code $tests _M_E close(PACK) or die("failed to close file $pack");