#!/usr/bin/perl use warnings; use strict; my $text = <<'END_MESSAGE'; Steuer-Apps fuers Smartphone versprechen eine moeglichst einfache und schnelle Steuererklaerung innerhalb von Minuten und hohe Rueckzahlungen von ueber 1000 Euro im Schnitt. Die Abgabe erfolgt digital per Knopfdruck, es gibt keinen Papierkram mehr, und nach ein paar Wochen soll das Geld schon da sein: Gemuetlich Steuern machen vom Sofa aus. Wir haben sechs dieser Steuer-Apps aus Deutschland getestet. Klartax, Steuerbot, Steuer Go, Taxfix, Wiso Steuer und wundertax sind gleichermaszen dafuer geeignet, eine Steuererklaerung abzugeben. Dennoch taten sich deutliche Unterschiede auf, nicht nur, was die Einfachheit und Unterstuetzung für Steuerlaien betrifft, sondern auch was die Abrechnung selbst angeht. END_MESSAGE my @lines = split(/\n/, $text); sub setBright { print "\033[1m"; } sub setNormal { print "\033[0m"; } sub processLine { my $line = shift; my @searches = qw(ae oe ue Ae Oe Ue sz); my %replaces = (ae => "ä", oe => "ö", ue => "ü", sz => "ß"); my ($c, $cn, $i, $input, $result); my @positions = (); my @a = (); my $cursor = 0; my @pieces = (); my $start = 0; my $l = length($line); while ($cursor < $l) { $c = substr($line, $cursor, 1); if ($cursor == $l - 1) { $cn = ""; } else { $cn = substr($line, $cursor + 1, 1); } for $i (@searches) { if ("$c$cn" eq $i) { push(@positions, $cursor); push(@a, $i); } } $cursor++; } for $i (@positions) { push(@pieces, substr($line, $start, $i - $start)); $start = $i + 2; } push(@pieces, substr($line, $start)); if ($#positions == -1) { return $line; } print "Starting editing: \n\n"; for $i (0 .. $#positions) { $result .= $pieces[$i]; print substr($line, 0, $positions[$i]); setBright(); print $a[$i]; setNormal(); print substr($line, $positions[$i] + 2); print "\n\n"; print "Change \"$a[$i]\" (y/n)? "; $input = ; chomp($input); if ($input eq "y") { $result .= $replaces{$a[$i]}; } else { $result .= $a[$i]; } if ($input eq "q") { print "Bye.\n"; exit 0; } print "\n"; } $result .= pop(@pieces); return $result; } my $linenr = 0; my $result; my $input; my @results = (); while ($linenr <= $#lines) { print "Line " . ($linenr + 1) . " of ". ($#lines + 1) . ". "; $result = processLine($lines[$linenr]); print "\nLine:\n\n$result\n\n"; print "Keep line (y/n)? "; $input = ; chomp($input); if ($input eq "y") { push(@results, $result); $linenr++; } if ($input eq "q") { print "Bye.\n"; exit 0; } print "\n"; } my $i; print "Result: \n"; for $i (@results) { print "$i\n"; }