in reply to Re: Parsing variables from login scripts
in thread Parsing variables from login scripts
___DATA___ MY_DIR=~/temp/module export MY_DIR MY_BIN=$MY_DIR/bin MY_DATA=$MY_DIR/data export MY_BIN MY_DATA __temp.pl__ #! /usr/local/bin/perl require "testpack.pm"; testpack::import(); print "DIR $DIR\n"; __testpack.pm__ package testpack; sub import { $conf_file = "conf.sh"; open (FILE, $conf_file) || die "Cant open file. \n"; while (<FILE>) { if (! (/^\W/ || /^export/)) { # ign. cmnts & ws chomp; print "$_\n"; my ($var, $value) = split(/\s*=\s+/, $_, 2); if ($value =~ s/^\$(\w+)//) { $value .= $env_var{$1} || ''; } $env_var{$var} = $value; my ($caller_package) = caller; *{"${caller_package}::${var}"} = $value; } # end if } # end while } # END import() definition
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: RE: Re: Parsing variables from login scripts
by chromatic (Archbishop) on Jul 29, 2000 at 04:15 UTC |