Thread Regulärer Ausdruck, Zeilenumbruch (15 answers)
Opened by Teesemmel at 2007-10-17 13:11

renee
 2007-10-17 15:34
#100978 #100978
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Hiermit bekommst Du "Blöcke":
Code (perl): (dl )
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
#!/usr/local/bin/perl
############################
use strict;
use warnings;
use Fcntl qw/O_RDONLY O_WRONLY O_CREAT O_EXCL/;

my $file = 'testinput.txt';
my $tmp = 'output.txt';

my $new = "das ist der eingefuegte Text\n";

sysopen(INPUT, $file, O_RDONLY) or die "unable to open the input file";    #Datei wird systemnah, nur zum Lesen, geöffnet
sysopen(OUTPUT, $tmp, O_WRONLY | O_CREAT) or die "unable to open job2.inp: $!";

local $/ = "\ntestende";

while(my $entry = <INPUT>){
    $entry =~ s/testende/${new}testende/g;
    
    warn ">>$entry<<";
    
    print OUTPUT $entry;
}
close (INPUT);
close (OUTPUT);
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/

View full thread Regulärer Ausdruck, Zeilenumbruch