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

Discussion in 'Perl Misc' started by cyrusgreats@gmail.com, Oct 17, 2008.

  1. Guest

    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
    , Oct 17, 2008
    #1
    1. Advertising

  2. Jürgen Exner, Oct 18, 2008
    #2
    1. Advertising

  3. <> wrote:

    > what should I do here



    You should repeat your post a few dozen more times.


    --
    Tad McClellan
    email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
    Tad J McClellan, Oct 18, 2008
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Roshawn

    Million Dollar Homepage Script

    Roshawn, Mar 18, 2010, in forum: ASP .Net
    Replies:
    12
    Views:
    1,238
    Roshawn
    Mar 24, 2010
  2. david
    Replies:
    3
    Views:
    104
    kaeli
    Aug 14, 2003
  3. Derek Richards

    Help Please! Thanks in advance.

    Derek Richards, Oct 21, 2003, in forum: Javascript
    Replies:
    2
    Views:
    81
    Derek Richards
    Oct 22, 2003
  4. PerlPerl
    Replies:
    12
    Views:
    161
    A. Sinan Unur
    May 30, 2005
  5. mike
    Replies:
    3
    Views:
    149
Loading...

Share This Page