Thread Datei nach String durchsuchen und in Datei ausgeben (42 answers)
Opened by QWERTZ7 at 2011-03-22 10:49

renee
 2011-03-22 13:02
#146767 #146767
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
my $file = '/pfad/zur/datei.txt';

my @inactive_ports;

{
    local $/ = "\n\n";
    open my $fh, '<', $file or die $!;
    while ( my $port_data = <$fh> ) {
        if ( $port_data =~ /Policy name\s*:\s*no policy applied/ ) {
            my ($port) = $port_data =~ /Port\s*:\s*([\w.]+)/;
            push @inactive_ports, $port;
        }
    }
    close $fh;
}

print "Inactive Ports: @inactive_ports\n";
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 Datei nach String durchsuchen und in Datei ausgeben