Logo

Programming-Idioms

History of Idiom 205 > diff from v5 to v6

Edit summary for version 6 by programming-idioms.org:
[Perl] Avoid comments in imports and snippets

Version 5

2019-09-29, 19:12:01

Version 6

2019-09-29, 19:13:14

Idiom #205 Get an environment variable

Read an environment variable with the name "FOO" and assign it to the string variable foo. 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 foo. If it does not exist or if the system does not support environment variables, assign a value of "none".

Extra Keywords
envvar os system
Extra Keywords
envvar os system
Imports
use 5.010; # for // operator
Imports
use 5.010;
Code
my $foo = $ENV{FOO} // 'none';
Code
my $foo = $ENV{FOO} // 'none';
Comments bubble
5.010 is for the // operator
Doc URL
https://perldoc.pl/perlvar#%ENV
Doc URL
https://perldoc.pl/perlvar#%ENV