in reply to Re^2: eval, Read environment variable and expand using eval
in thread eval, Read environment variable and expand using eval
There is a subtle yet important difference between defined and exists on hash and array elements. Defined will autovivify your hash element and make its value undefined.
Perhaps you meant this?
$r = (exists $ENV{INFORMIXSQLHOSTS}) ? $ENV{INFORMIXSQLHOSTS} : 'sqlho +st')
If you want to check every possiblity this would be the best. However I usually just do the exists() check.
$r = ((exists $ENV{INFORMIXSQLHOSTS} && defined($ENV{INFORMIXSQLHOSTS} +) && length($ENV{INFORMIXSQLHOSTS}) ) ? $ENV{INFORMIXSQLHOSTS} : 's +qlhost'));
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: eval, Read environment variable and expand using eval
by Anonymous Monk on Feb 19, 2010 at 15:04 UTC | |
by bot403 (Beadle) on Feb 19, 2010 at 17:08 UTC | |
by ikegami (Patriarch) on Feb 19, 2010 at 21:29 UTC | |
by Anonymous Monk on Feb 19, 2010 at 17:36 UTC |