TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [TCLUG:2562] learning perl and variables



Sandipan Panigrahi wrote:
> 
> All environment variables are available from the hash ENV in perl.
> To access an environment variable use :
> $ENV{LOGNAME}
> or to get the Home directory use
> $ENV{HOME}

Careful there.  While perl does allow strings to be unquoted if they're
the only thing used as the key for a hash, it's really an unsafe thing
to do.  If, four months from now, you write some code like this at top:

	open HOME, "</home/mydir";

your $ENV{HOME} line will break, and do so with confusing errors.
Something
like:
	$ENV{'HOME'} is much better

--
Ry4an Brase - http://acm.cs.umn.edu/~ry4an - 612-623-9946
'If you're not a rebel when you're 20 you've got no heart; if
 you're  not establishment when you're 30 you've got no brain.'