Advertisement
Guest User

Untitled

a guest
Nov 1st, 2015
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.59 KB | None | 0 0
  1. use strict;
  2. use warnings;
  3. use v5.18;
  4.  
  5. open (my $fh, "<", 'input.txt');
  6. open (my $fh_out, ">", 'output.txt');
  7.  
  8. my $prev_line;
  9. foreach $current_line (<$fh>) {
  10.  
  11.     my $out_line = $current_line;
  12.    
  13.     if ($current_line =~ /^msgstr/ and $prev_line =~ /^msgid/){
  14.  
  15.         my ($prev_var) = $prev_line =~ /^msgid\ \"(.+)+\"/;
  16.         my ($cur_var) = $current_line =~ /^msgid\ \"(.+)+\"/;
  17.  
  18.         if ($cur_var eq $prev_var){
  19.             $out_line =~ s/$cur_var//;
  20.         }
  21.     }
  22.  
  23.     print $fh_out $out_line;
  24.    
  25.     $prev_line = $current_line;
  26. }
  27.  
  28. close($fh);
  29. close($fh_out);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement