Thread Text blockweise parsen (9 answers)
Opened by Lauvia at 2014-03-21 11:07

renee
 2014-03-21 16:42
#174359 #174359
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Vielleicht hilft Dir
Code: (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
26
27
28
29
30
!/usr/bin/perl

use strict;
use warnings;

use Data::Dumper;

my $file = 'test.txt';

{
open my $fh, '<', $file or die "$file: $!";

# change block separator to have one complete frame
# read per iteration
local $/ = "\nFRAME NAME:";

# read the blocks
while ( my $frame = <$fh> ) {
next if $. == 1; # skip the "header"

chomp $frame; # remove block separator

# print the frame
print "This is a frame:\n",
'=' x 30, "\n",
$frame, "\n",
'=' x 30;
}
close $fh;
}
weiter...
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 Text blockweise parsen