Hast Du die zweite Variante
#!/usr/bin/perl
use strict;
use warnings;
my $lastmatch = 0;
while (<>) {
my $match = m~ROT~;
print if $match or $lastmatch;
$lastmatch = $match;
}
auch mal getesetet? Müsste das gleiche machen, aber nur die Hälfte der Vergleiche benötigen. Probier mal dies:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/perl
use strict;
use warnings;
my @rot;
my @vio;
my $lastmatchrot = 0;
my $lastmatchvio = 0;
while (<>) {
my $matchrot = m~ROT~;
my $matchvio = m~VIO~;
push @rot, $_ if $matchrot or $lastmatchrot;
push @vio, $_ if $matchvio or $lastmatchvio;
$lastmatchrot = $matchrot;
$lastmatchvio = $matchvio;
}
my $fh;
open ($fh, ">Ausgabedatei.txt") or die "Kann Ausgabedatei nicht öffnen: $!";
print $fh "ROT:\n";
print $fh $_ for @rot;
print $fh "\nVIO:\n";
print $fh $_ for @vio;
close ($fh) or die "Kann Ausgabedatei nicht schließen: $!";
(wieder ungetestet)\n\n
<!--EDIT|Crian|1092057615-->
s--Pevna-;s.([a-z]).chr((ord($1)-84)%26+97).gee; s^([A-Z])^chr((ord($1)-52)%26+65)^gee;print;
use strict; use warnings; Link zu meiner Perlseite