1

Here is a WSL bash session in which I attempt to access an Environment variable within a perl one liner:

$ ln='Hello World'
$ echo $ln
Hello World
$ perl -E 'say $ENV{q(ln)}'

$

Why does the perl expression $ENV{q(ln)} not contain the expected Environment variable ln ?

tripleee
  • 158,107
  • 27
  • 234
  • 292
Wes
  • 373
  • 2
  • 12

1 Answers1

1

You need to export the environment variable.

$ ln='Hello World'
$ export ln

or

$ export ln='Hello World'

See section 3.2.3 in the Bash Beginners' Guide, and the top answer to this stackoverflow question

Jim Davis
  • 4,838
  • 1
  • 25
  • 22