[Omaha.pm] Proper way to test a variable with strict and -w?

Daniel Linder dan at linder.org
Fri Sep 2 09:33:37 PDT 2005



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, September 2, 2005 07:01, Jay Hannah wrote:

> Actually, I wouldn't 'use Env' at all. That's just a
"shortcut" for

> Perl's built-in %ENV. I'd do this:

> 

> #!/usr/bin/perl -w

> 

> $ENV{Var1} ||= "DefaultValue1";

> $ENV{Var2} ||= "DefaultValue2";

> my $Var3 = "$ENV{Var1} -- $ENV{Var2}";



Since the "||" operator is more well known with my team, I ended
up using this:

my $Var1 = $Env{Var1} || "DefaultValue1";



Dan



- - - - -

"Wait for that wisest of all counselors, time." -- Pericles

"I do not fear computer, I fear the lack of them." -- Isaac
Asimov

GPG fingerprint:6FFD DB94 7B96 0FD8 EADF  2EE0 B2B0 CC47 4FDE 9B68

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFDGH7hsrDMR0/em2gRAr6UAKCmiSml7lQc2jIf3lFTNkF+U9H3nQCgrvsU
j+IxGQzJp4qgp//cYiPXRaA=
=Hegb
-----END PGP SIGNATURE-----
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/omaha-pm/attachments/20050902/7ecb11cb/attachment.html


More information about the Omaha-pm mailing list