OP said:
"From what I understand, your script looks for 'Total:' and then for
following line with numbers, reads them and prints them. That is what I
need. However, there are 3 sections with 'Total:' and I am interested only
in one of them. "



2 preceding bits of info determine which is the right one.

-Tom Kinzer


-----Original Message-----
From: R. Joseph Newton [mailto:[EMAIL PROTECTED]
Sent: Monday, December 08, 2003 7:02 PM
To: Tom Kinzer
Cc: Katka a Daniel Dunajsky; Beginners Perl
Subject: Re: Reading a log file, again


Tom Kinzer wrote:

> Try this:
>
> Caveat: This all assumes LOTS about the format of your data being
> consistent, and so should be treated as a "quick and dirty" as opposed to
> anything resembling a robust application...  I'm not sure what your
> intention with the script is, but is worth mentioning.
>
> -Tom Kinzer

Hi Tom,

I think this may be getting too complicated.  My understanding is that the
OP was
actually interested in a single datum, the total figure at the bottom.  I
haven't
seen any clarification indicating otherwise, so I would suggest just doing
it:

my $junk = '';
$junk = <DATA> until $junk =~/^Total/;
$pot_o_gold = <DATA>;
$pot_o_gold =~ s/^\s*//;
chomp $pot_o_gold;
print "I got my value, and it's $pot_o_gold\n";
__DATA__
...
Format          count
a               100
b                51
c               130
d                 5
e                 6
Total:          ---
                292
I got my value, and it's 292

Remember KISS.

Joseph


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to