what you can do is open the file, read it line by line and add it to a 
total:

#!/usr/bin/perl -w
use strict;

#-- our total
my $total = 0;

#-- try open the file. if we can't, print the reason
open(FILE,"fileA") || die $!;

#-- read the file line by line and add it to $total.
#-- normally, when you read from a file, the line will
#-- contains a newline character at the end and you will
#-- want to remove it with the chop or chomp function.
#-- in your case, it isn't neccessary so i have avoid it.
$total += $_ while(<FILE>);

#-- finished. close the file
close(FILE);

#-- print the total with a $ sign
print "\$$total\n";

__END__

i notice that you have the line "0014595h" in
your file. this will cause Perl(with the -w thingy)
to issue a warning when we are executing the "$total += $_"
line. the above simply ignore that and turns "0014595h" into "14595"

david

James Parsons wrote:

> This is probably a very simple question for the group.but here's goes.
> Please keep in mind I'm just a beginner.
> 
> I have  the following file and I would like to add the lines in the file
> and get a total with a floating $ sign.
> 
> fileA.
> 
> 00000010
> 00000032
> 00000043
> 00000032
> 00000014
> 00000042
> 00000039
> 00003103
> 00230004
> 0014595h
> 
> 
> Thanks
> 
> James Parsons


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to