danield wrote: > Hello all, > > I have received a solution for my problem (reading from log) from Tom > Kinzer. The code is: > > #!/usr/bin/perl -w > use strict; > my $log_file = "/appl/log/00004e4d/20031130.txt"; > open LOG, "< $log_file" or die "Could not open file $!"; > while ( <LOG> ) { > chomp; > if ( /^GTotal Content:/ ) { > my ($gtotal_content, $value) = split(/:/, $_); > print $value; > } > } > close LOG; > > The problem is this code returns no value. When I remove all preceding > lines from the log (20031130.txt) and keep there only that GTotal > Content: 14,741,322, I will get desired result (14,741,322) > > What may be a solution for this?
As I recall, your desired data was on the line following that label. Since you started a new thread here, I'm not going to hunt down the original. If this is the case, though, then you should still be moving forward another line before you try to extract the data. Also: 1) There is no point in chomp()ing all input lines. You are testing the start of the line, and chomp affects only the end. I'd suggest moving the chomp inside the if block. 2) From the sample posted on the original, it looks like you will need to trim leading white space before taking a value. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>