in reply to Parsing text sections
#!/usr/bin/perl -w use strict; while (<DATA>) { next unless /^@/; my $header = ($_ =~ m/([\w:\s]+)/)[0]; #tweak as necessary $header =~ s/\s*$//; $header =~ s/^\s*//; my @lines = get_data_4_header($header); print "** lines for \"$header\" **\n"; print @lines; print "\n"; } sub get_data_4_header { my $header = shift; #not used here, but could be if needed.. my @result=(); <DATA>; #throw away a line (i.e., the next --- line) while ( ($_ = <DATA>) !~ m/^-/) { push @result,$_; } return @result; } =Prints: ** lines for "Callsites: 2" ** ID Lev File/Address Line Parent_Funct MPI_Call 1 0 0x8048ad5 [unknown] Reduce 2 0 0x8048a3b [unknown] Bcast ** lines for "Aggregate Time" ** Call Site Time App% MPI% COV Bcast 2 9.5 24.71 65.75 0.59 Reduce 1 4.95 12.87 34.25 1.35 =cut __DATA__ ------------------------------------------------------------------- @--- Callsites: 2 ------------------------------------------------- ------------------------------------------------------------------ ID Lev File/Address Line Parent_Funct MPI_Call 1 0 0x8048ad5 [unknown] Reduce 2 0 0x8048a3b [unknown] Bcast ------------------------------------------------------------------ @--- Aggregate Time (top twenty, descending, milliseconds) --- ----------------------------------------------------------------- Call Site Time App% MPI% COV Bcast 2 9.5 24.71 65.75 0.59 Reduce 1 4.95 12.87 34.25 1.35 ----------------------------------------------------------------
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Parsing text sections
by betacentauri (Sexton) on Jul 04, 2010 at 11:14 UTC | |
by Marshall (Canon) on Jul 05, 2010 at 10:32 UTC |