Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
I have a basic perl script that is for a pay per click advert. It stores users in a file and has basic password code to login and see what is owed.
The user, password, privalege (user / admin), pence per click and number of clicks so far is stored in a txt file.
This is part of the script:open(FILE,"details.txt");
@raw = <FILE>;
close FILE;
$line=0;
foreach $line (@raw) {
chomp $line;
($user,$pass,$priv,$ppc,$nc) = split /:/,$line;What I want to do is multiply $ppc and $nc together for each user and then add them all together set it as a variable to show the total of all users to be displayed in an admin account (so it's possible to see profit :D ).
How can I do this?
Many Thanks,
Davros

$total = 0;
open(FILE,"details.txt" or die $!);
while (<FILE>) {
chomp;
($user,$pass,$priv,$ppc,$nc) = split /:/;
$product = $ppc * $nc;
$total += $prod;
}
close FILE;
print $total;

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |