Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use strict;
- use warnings;
- use v5.18;
- my @file_array;
- my $current_line = undef;
- my $prev_line = undef;
- open (my $fh, "<", 'input.txt');
- while(readline($fh)){
- $current_line = $_;
- if ($current_line =~ /^msgstr/ and $prev_line =~ /^msgid/){
- #print $prev_line;
- $prev_line =~ /^msgid\ \"(.+)+\"/;
- my $prev_var = $1;
- #print $current_line;
- $current_line =~ /^msgid\ \"(.+)+\"/;
- my $cur_var = $1;
- if ($cur_var eq $prev_var){
- $current_line =~ s/$cur_var//;
- }
- push @file_array, $current_line;
- }
- else {
- push @file_array, $current_line;
- }
- $prev_line = $current_line;
- }
- close $fh;
- my $file_text = join "", @file_array;
- print $file_text;
- open (my $fh_out, ">", 'output.txt');
- print $fh_out $file_text;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement