
want perl demo .cshrc,.login
Quote:
> does writing .cshrc and .login files in perl make sense?
Well ... since Perl would be running as a child to your login shell,
it is unable to set the parent shell's environment directly (this is
due to the structure of Unix, not perl itself ... children cannot
directly alter parents' environments). This means that 'setenv' stuff
couldn't be directly done. Since 'set' variables and aliases are
local to the current invocation of your C shell, the same holds true
with these.
However, you could make your .cshrc look something like this:
eval `cshrc.pl`
... where 'cshrc.pl' is a perl script. This script could look something
like this:
#!/usr/local/bin/perl
# Do various system initialization things here not involving
# aliases, set's, or setenv's.
# etc. ...
# End of system initializations.
# Handle aliases like this:
$alias{'ls'} = '/bin/ls -FACs'
$alias{'j'} = 'jobs -l'
# etc. ...
# Handle set's like this:
$set{'noclobber'} = '1';
$set{'path'} = '( . ~/bin /etc /usr/ucb /usr/bin /bin )';
# etc. ...
$ENV{'VISUAL'} = '/usr/local/bin/emacs';
$ENV{'PAGER'} = '/usr/local/bin/less';
# Note the embedded double quotes in the next one ...
$ENV{'ORGANIZAION'} = '"The name of my organization"';
# etc. ...
# Now, generate 'alias', 'set', and 'setenv' statements
# and print them to stdout:
while (($key, $value) = each %alias) {
print "alias $key '$value'\n";
}
while (($key, $value) = each %set) {
print "set $key = $value\n";
}
while (($key, $value) = each %ENV) {
print "setenv $key $value\n";
}
Since you are generating 'alias', 'set', and 'setenv' statements to
stdout and evaluating them in the C Shell via the 'eval' and backquote
constructs, they will all get properly evaluated in the context of
your shell. Same holds true for a "login.pl" script for your .login.
--
Lloyd Zusman 01234567 <-- The world famous Indent-o-Meter.
To get my PGP public key automatically mailed to you, please
send me email with the following string as the subject:
mail-request public-key