File indexing completed on 2024-04-28 05:04:02

0001 #!/usr/bin/perl
0002 #
0003 # SPDX-FileCopyrightText: 2018 Thomas Baumgart <tbaumgart@kde.org>
0004 # SPDX-License-Identifier: GPL-2.0-or-later
0005 #
0006 # ----------------------------------------------------------------------
0007 #
0008 # This tool reads a KMyMoney XML file on stdin and writes it to stdout
0009 #
0010 # While doing so it fixes broken PRICEPAIRs by removing the entries
0011 
0012 my $skip = 0;
0013 
0014 while(<>) {
0015   if ($_ =~ /<PRICEPAIR to=\"([^\"]*)\" from=\"([^\"]*)\">/) {
0016     my $from_id = $2;
0017     my $to_id = $1;
0018 
0019     $skip = 1 if ($to_id =~ /E\d{6}/);
0020     print $_ if ($skip == 0);
0021 
0022   } elsif ($_ =~ /<\/PRICEPAIR>/) {
0023     print $_ if ($skip == 0);
0024     $skip = 0;
0025 
0026   } else {
0027     print $_ if ($skip == 0);
0028   }
0029 }
0030