SOS: Need help on this script if you can ...million thanks in advance

C

cyrusgreats

Hello good people out there. I need to write a perl script that will
parse the log and generate the following output:a flat text file in
the following format:

customer_name|product_category|item_description|cost

An example log file could be:
Pedro|groceries|apple|1.42
Nitin|tobacco|cigarettes|15.00
Susie|groceries|cereal|5.50
Susie|groceries|milk|4.75
Susie|tobacco|cigarettes|15.00
Susie|fuel|gasoline|44.90
Pedro|fuel|propane|9.60

1.A report of the total revenue resulting from each customer.
2.A report for each customer showing how much of their spending went
to each category.
With the above example log file, the script should output should be
something like:
Total Revenue:
Pedro - $11.02
Nitin - $15.00
Susie - $70.15

Purchases by Pedro:
groceries - $1.42
fuel - $9.60

Purchases by Nitin:
tobacco - $15.00

Purchases by Susie:
groceries - $10.25
fuel - $44.90
tobacco - $15.00

#!/usr/bin/perl
use strict;

my $file = "inventory";
open (FILE, $file) || die ("Could not open file. $!");

foreach my $line (FILE) {
my ($customer_name, $product_cat, $item_desc, $cost) = split("|",
$line);


what should I do here
Any help will be appreciated...million thanks in advanceHello good
people out there. I need to write a perl script that will parse the
log and generate the following output:
a flat text file in the following format: customer_name|
product_category|item_description|cost
An example log file could be:
Pedro|groceries|apple|1.42
Nitin|tobacco|cigarettes|15.00
Susie|groceries|cereal|5.50
Susie|groceries|milk|4.75
Susie|tobacco|cigarettes|15.00
Susie|fuel|gasoline|44.90
Pedro|fuel|propane|9.60

1.A report of the total revenue resulting from each customer.
2.A report for each customer showing how much of their spending went
to each category.
With the above example log file, the script should output should be
something like:
Total Revenue:
Pedro - $11.02
Nitin - $15.00
Susie - $70.15

Purchases by Pedro:
groceries - $1.42
fuel - $9.60

Purchases by Nitin:
tobacco - $15.00

Purchases by Susie:
groceries - $10.25
fuel - $44.90
tobacco - $15.00

#!/usr/bin/perl
use strict;

my $file = "inventory";
open (FILE, $file) || die ("Could not open file. $!");

foreach my $line (FILE) {
my ($customer_name, $product_cat, $item_desc, $cost) = split("|",
$line);


what should I do here
Any help will be appreciated...million thanks in advanceHello good
people out there. I need to write a perl script that will parse the
log and generate the following output:
a flat text file in the following format: customer_name|
product_category|item_description|cost
An example log file could be:
Pedro|groceries|apple|1.42
Nitin|tobacco|cigarettes|15.00
Susie|groceries|cereal|5.50
Susie|groceries|milk|4.75
Susie|tobacco|cigarettes|15.00
Susie|fuel|gasoline|44.90
Pedro|fuel|propane|9.60

1.A report of the total revenue resulting from each customer.
2.A report for each customer showing how much of their spending went
to each category.
With the above example log file, the script should output should be
something like:
Total Revenue:
Pedro - $11.02
Nitin - $15.00
Susie - $70.15

Purchases by Pedro:
groceries - $1.42
fuel - $9.60

Purchases by Nitin:
tobacco - $15.00

Purchases by Susie:
groceries - $10.25
fuel - $44.90
tobacco - $15.00

#!/usr/bin/perl
use strict;

my $file = "inventory";
open (FILE, $file) || die ("Could not open file. $!");

foreach my $line (FILE) {
my ($customer_name, $product_cat, $item_desc, $cost) = split("|",
$line);


what should I do here
Any help will be appreciated...million thanks in advanceHello good
people out there. I need to write a perl script that will parse the
log and generate the following output:
a flat text file in the following format: customer_name|
product_category|item_description|cost
An example log file could be:
Pedro|groceries|apple|1.42
Nitin|tobacco|cigarettes|15.00
Susie|groceries|cereal|5.50
Susie|groceries|milk|4.75
Susie|tobacco|cigarettes|15.00
Susie|fuel|gasoline|44.90
Pedro|fuel|propane|9.60

1.A report of the total revenue resulting from each customer.
2.A report for each customer showing how much of their spending went
to each category.
With the above example log file, the script should output should be
something like:
Total Revenue:
Pedro - $11.02
Nitin - $15.00
Susie - $70.15

Purchases by Pedro:
groceries - $1.42
fuel - $9.60

Purchases by Nitin:
tobacco - $15.00

Purchases by Susie:
groceries - $10.25
fuel - $44.90
tobacco - $15.00

#!/usr/bin/perl
use strict;

my $file = "inventory";
open (FILE, $file) || die ("Could not open file. $!");

foreach my $line (FILE) {
my ($customer_name, $product_cat, $item_desc, $cost) = split("|",
$line);


what should I do here
Any help will be appreciated...million thanks in advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top