1 package IPC::Run3::ProfLogReader;
7 IPC::Run3::ProfLogReader - read and process a ProfLogger file
11 use IPC::Run3::ProfLogReader;
13 my $reader = IPC::Run3::ProfLogReader->new; ## use "run3.out"
14 my $reader = IPC::Run3::ProfLogReader->new( Source => $fn );
16 my $profiler = IPC::Run3::ProfPP; ## For example
17 my $reader = IPC::Run3::ProfLogReader->new( ..., Handler => $p );
24 Reads a log file. Use the filename "-" to read from STDIN.
32 =head2 C<< IPC::Run3::ProfLogReader->new( ... ) >>
37 my $class = ref $_[0] ? ref shift : shift;
38 my $self = bless { @_ }, $class;
40 $self->{Source} = "run3.out"
41 unless defined $self->{Source} && length $self->{Source};
43 my $source = $self->{Source};
45 if ( ref $source eq "GLOB" || UNIVERSAL::isa( $source, "IO::Handle" ) ) {
46 $self->{FH} = $source;
48 elsif ( $source eq "-" ) {
49 $self->{FH} = \*STDIN;
52 open PROFILE, "<$self->{Source}" or die "$!: $self->{Source}\n";
53 $self->{FH} = *PROFILE{IO};
59 =head2 C<< $reader->set_handler( $handler ) >>
63 sub set_handler { $_[0]->{Handler} = $_[1] }
65 =head2 C<< $reader->get_handler() >>
69 sub get_handler { $_[0]->{Handler} }
71 =head2 C<< $reader->read() >>
79 my @ln = split / /, <$fh>;
82 return 1 unless $self->{Handler};
86 ## Ignore blank and comment lines.
87 return 1 if @ln == 1 && ! length $ln[0] || 0 == index $ln[0], "#";
89 if ( $ln[0] eq "\\app_call" ) {
91 my @times = split /,/, pop @ln;
92 $self->{Handler}->app_call(
103 elsif ( $ln[0] eq "\\app_exit" ) {
105 $self->{Handler}->app_exit( pop @ln, @ln );
108 my @times = split /,/, pop @ln;
109 $self->{Handler}->run_exit(
125 =head2 C<< $reader->read_all() >>
127 This method reads until there is nothing left to read, and then returns true.
144 Copyright 2003, R. Barrie Slaymaker, Jr., All Rights Reserved
148 You may use this module under the terms of the BSD, Artistic, or GPL licenses,
153 Barrie Slaymaker E<lt>barries@slaysys.comE<gt>