Thread Bestimmte zeilen einer datei einlesen: zeilen eytrahieren
(4 answers)
Opened by Gast at 2007-03-27 17:33
Naja, Du hast es also als "Stream". Du kannst es auf zwei unterschiedliche Weisen machen:
Möglichkeit 1: Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 open (VOL, "$ssh $filer aggr show_space $aggr |") || die "Cannot connect to $filer: $! \n"; while (my $line = <VOL>){ if( $line =~ /^\s*Volume/ ){ $bool = 1; } next unless $bool; print $line; if( $line =~ /^\n+$/ ){ $bool = 0; } } # end while VOL close (VOL); Möglichkeit 2: Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 my $string = ""; open (VOL, "$ssh $filer aggr show_space $aggr |") || die "Cannot connect to $filer: $! \n"; while (my $line = <VOL>) { $string .= $line; } # end while VOL close (VOL); my @parts = split /\n\n/,$string; for my $part (@parts){ next unless $part =~ m!^\s*Volume!; print ("Habe: $part\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/ |