in reply to Inserting Variable Through Perl

You can use %ENV to access environment variables, or as a trick you can use the -s switch:

$ cat test.txt one two three $ part="C:00000092666270:53882159774" $ echo $part C:00000092666270:53882159774 $ perl -pse 'print qq{foo = [ "$bar" ]\n} if $. == 3' -- -bar="$part" +test.txt one two foo = [ "C:00000092666270:53882159774" ] three $ export part $ perl -pe 'print qq{foo = [ "$ENV{part}" ]\n} if $. == 3' test.txt one two foo = [ "C:00000092666270:53882159774" ] three

I removed the -i for demonstration purposes, you can just add it back in, also I used -p instead of -n to save a bit of typing, but neither of those changes are necessary for the ideas I'm showing to work.

Although personally, I usually prefer to just write the whole thing in Perl instead of intermixing Perl and shell scripting.