in reply to Parsing variables from login scripts
package testpack; # Setup Common Variables sub import { $conf_file = "conf.sh"; open (FILE, $conf_file) || die "Cant open file. \n"; while (<FILE>) { if (! (/^\W/ || /^export/)) { # ignore irrelevants chomp; $var, $value) = split(/=/, $_, 2); if ($value =~ s/^\$(\w+)//) { $value = "$env_var{$1}$value" || ''; } $env_var{$var} = $value; my ($caller_package) = caller; *{"${caller_package}::${var}"} = \$value; } # end if } # end while } # END import() definition 1;
|
|---|