Changeset 28128 for gs3-extensions

Show
Ignore:
Timestamp:
26.08.2013 13:48:56 (6 years ago)
Author:
davidb
Message:

Code as written (with 'eval') was resulting in a 'Useless use of private variable in void context. Refactored to avoid this.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • gs3-extensions/solr/trunk/src/perllib/solrserver.pm

    r27858 r28128  
    212212{ 
    213213    my $self = shift @_; 
    214     my ($src_file,$dst_file,$re_substitutions) = @_; 
    215  
    216     my $sep = shift @_ || "/"; 
    217     my $flags = shift @_ || "g"; 
     214 
     215    my $src_file = shift @_; 
     216    my $dst_file = shift @_; 
     217    my $re_substitutions = shift @_; 
    218218 
    219219    # $re_substitutions is a hashmap of the form: [re_key] => subst_str 
    220  
     220     
    221221    my $content = ""; 
    222222 
     
    241241    # and flags (default 'g') to be parameterized 
    242242 
    243     my $eval_str = "\$content =~ s$sep$re_key$sep$subst_str$sep$flags"; 
    244  
    245     eval { 
    246         $eval_str; 
    247     }; 
    248     if ($@) { 
    249         print STDERR "Warning: failed to evaluate\n   $eval_str\n$@\n"; 
    250     } 
    251  
     243    $content =~ s/$re_key/$subst_str/g; 
    252244    } 
    253245     
     
    270262    my $web_solrxml = &util::filename_cat($web_solr_ext_dir, "solr.xml"); 
    271263 
    272     my $replacement_map = { "$gsdl3home" => "\\\@gsdl3home\\\@" }; 
    273   
    274     $self->filtered_copy($web_solrxml,$web_solrxml_in,$replacement_map, "^", "g"); 
     264    my $gsdl3home_re = &util::filename_to_regex($gsdl3home); 
     265 
     266    my $replacement_map = { qr/$gsdl3home_re/ => "\@gsdl3home\@" }; 
     267 
     268    $self->filtered_copy($web_solrxml,$web_solrxml_in,$replacement_map); 
    275269} 
    276270 
     
    285279    my $web_solrxml = &util::filename_cat($web_solr_ext_dir, "solr.xml"); 
    286280     
    287     my $replacement_map = { "\\\@gsdl3home\\\@" => "$gsdl3home" }; 
    288   
    289     $self->filtered_copy($web_solrxml_in,$web_solrxml,$replacement_map, "^", "g"); 
     281    my $gsdl3home_re = &util::filename_to_regex($gsdl3home); 
     282 
     283    my $replacement_map = { qr/\@gsdl3home\@/ => $gsdl3home_re }; 
     284 
     285    $self->filtered_copy($web_solrxml_in,$web_solrxml,$replacement_map); 
    290286} 
    291287