Thread Zeilensprung in einer Ausgabe (15 answers)
Opened by Gast at 2008-11-18 14:19

renee
 2008-11-18 15:01
#116361 #116361
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
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
#!/usr/bin/perl

use strict;
use warnings;
use Getopt::Long;

GetOptions(
  'sp=s' => \my $sp,
  'p=n'   => \my $port,
);

my $file = 'file.txt';

open my $fh, '<', $file or die $!;
{
    local $/ = "\n\n";
    while(my $block = <$fh> ){
        next unless index( $block, 'SP Name: SP ' . $sp ) != -1  and
                    index( $block, 'SP Port ID: ' . $port ) != -1;
        my ($status) = $block =~ /Link Status: (\w+)/;
        print "Link status for SP $sp (Port $port): $status\n";
    }
}
close $fh;
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 Zeilensprung in einer Ausgabe