Logo

Programming-Idioms

History of Idiom 205 > diff from v1 to v2

Edit summary for version 2 by daxim:
New Perl implementation by user [daxim]

Version 1

2019-09-29, 17:07:05

Version 2

2019-09-29, 17:15:38

Idiom #205 Get an environment variable

Read an environment variable with the name FOO and assign it to the string variable env. If it does not exist or if the system does not support environment variables, assign a value of "none".

Idiom #205 Get an environment variable

Read an environment variable with the name FOO and assign it to the string variable env. If it does not exist or if the system does not support environment variables, assign a value of "none".

Imports
use 5.010; # for // operator
Code
my $env = $ENV{FOO} // 'none';
Doc URL
http://p3rl.org/var#%ENV