# -*- perl -*- $PARAMS{'Task/Params/CellRefinementLevel'}=7; $PARAMS{'Task/Params/GridCellSizeInXDirection'}=100; $PARAMS{'Task/Params/GridCellSizeInYDirection'}=100; 1; # Required for end of config file. #### use XML::Twig; use vars qw (%PARAMS); do 'params.cfg'; while( my($key,$val) = each(%PARAMS) ) { substr($val,0,0) = 'sub { upd_param(@_,'; $val .=' },'; $PARAMS{$key} = $val; } my $twigT= new XML::Twig( twig_roots => { %PARAMS,}, twig_print_outside_roots => 1, ); $twigT->parsefile( $task_file); $twigT->purge; #probably not needed sub upd_param { my( $t, $param,$new_param)= @_; my $item = defined($new_param)? $new_param:$param->text; $param->set_text($item); # change it $param->print; # print updated value $t->purge; # free the memory }