$ 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