in reply to Re^2: evaluating a string into the executing program
in thread evaluating a string into the executing program

Are you trying to execute the content of the config files? If so, a simple require "config.pl" (or whatever the config file/script is named) will do that.

If you just need to extract specific information from the config file without executing it, then that gets a bit trickier, yeah. I can't really say how to handle that case without a sample of what one of these files looks like, which contents you want from it, and what you want to do with them.

Replies are listed 'Best First'.
Re^4: evaluating a string into the executing program
by deorth (Scribe) on Jul 14, 2007 at 04:33 UTC
    Well, simplistically I could do :
    open(FILE, "< $file") || die "Couldn't open $file: $!\n"; @array = <FILE>; ## Assume no multiline stuff.. for now @strings = grep(/^\s*\@$arrayname\s*=\s*/, @array);

    $string[0] then contains the piece of perl code I wish to execute. Now I thought of really hacky stuff like dropping it into a tempfile and then require'ing the file, but thats just icky. :)