The following programs calculates sum totals of the values in file (Values.dat).

Values.dat:
---------------
$30,45
$0,50


How do I  handle the $ sign infront of the values.
I want the $ sign in the result when calulating sum of these values. 
In my program I left out the $ sign cause I dont know.

--------------------------------------------------------------------------------------------------------
#!/usr/bin/perl -w
open(INPUT, "Values.dat") || die;
my $value;
while (<INPUT>) {
   if (/\d*,\d{3}/) {s/,//; $value += $_; }
   else {print "warning: line of unexpected format ($_)\n";}
}
1 while( $value =~ s/(\d*,)(\d{3})(?=\.|,|\z)/$1,$2/ );
print $value;
close(INPUT);
-------------------------------------------------------------------------------------------------------


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

Reply via email to