# This is a nasty little sub that parses out what Environmental # Var to retrieve and then inserts it into the string sub getEnvValue { my $envValue = ""; # set the workspace $_ = $_[0]; # As long as a question mark exists keep working # on it (Bad place for a possible 'hang' or looping # problem.) while ( /\$/ ) { # Seperate out the VarName and the remaining string /(\\\$)(\w+)(.*)/ ; # eliminate surrounding quoutes from string # get that freakin delimeter my $delimeter = $`; my $envVarString = $2; my $workString = $3; debug( "\$delimeter = $delimeter\n \$envVarString = $envVarString\n \$workString = $workString\n", 0 ); # Get the environments value and substitute it into the # current line if it exists if ( $ENV{$envVarString} ) { $envValue = $delimeter . $ENV{$envVarString} . $workString; s/$envVarString/$ENV{$envVarString}/g; } else { $envValue = $delimeter . "NA" . $workString; s/$envVarString/NA/g } debug( "Harvest::FileFuc::getEnvValue\n \$Workpace = $_\n \$workString = $workString\n So far returning $envValue\n",1); # If theres no more $'s in the string pop it back on # the return value $_ = $envValue; } # Return the work return $envValue; }