Satheesh Ramakrishnan wrote:
> 
> All,
> 
> How do I assign 1298b to some scalar variable from the string below.
> 
> context_config_file = "1298b";

        this is probably a cookbook, but....

##################################################################
        require 5; # for (.*?) regex goodness
        my (%cfg, $key, $val,
        );

        open(CFG, $config_file) || die "$0: can't open [$config_file]!\n$!\n";
        while(<CFG>) {
                chomp;
                # split on whitespace(or not) and the '=' token
                ($key, $val) = split(/(\s*?)\=(\s*?)/);
                $cfg{$key} = $val;
        }
##################################################################

        This should probably do it for you, leaving the configuration data in a
handy hash.

Cheers,
- Matt

Reply via email to