|< 1 2 >| | 18 Einträge, 2 Seiten |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#! /usr/bin/perl
use strict;
use warnings;
use Tie::File;
my $file = "./test.txt";
my $index;
open(FILE,"<$file") or die $!;
while(my $line = <FILE>){
$index = $. if($line =~ /NOID/);
}
close FILE;
if(defined $index){
tie my @array,'Tie::File',$file or die $!;
splice(@array,$index-1,4);
untie @array;
}
perl -ne '$cnt=4 if /NOID/; print unless $cnt && $cnt--;' datei_alt.txt > datei_neu.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use strict;
use warnings;
use Tie::File;
my $file = "./test.txt";
tie my @array,'Tie::File',$file or die $!;
my $index = undef;
foreach (0..$#array) {
$index = $_, last if $array[$_] =~ /NOID/;
}
splice(@array,$index,4) if defined($index);
untie @array;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#! /usr/bin/perl
use strict;
use warnings;
use Tie::File;
my $file = "./test.txt";
my $index;
open(FILE,"<$file") or die $!;
while(my $line = <FILE>){
$index = $. if($line =~ /NOID/);
}
close FILE;
if(defined $index){
tie my @array,'Tie::File',$file or die $!;
splice(@array,$index-1,4);
untie @array;
}
perl -ne '$cnt=4 if /NOID/; print unless $cnt && $cnt--;' datei_alt.txt > datei_neu.txt
|< 1 2 >| | 18 Einträge, 2 Seiten |