[30685] in Perl-Users-Digest
Perl-Users Digest, Issue: 1930 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 17 21:09:47 2008
Date: Fri, 17 Oct 2008 18:09:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 17 Oct 2008 Volume: 11 Number: 1930
Today's topics:
Re: "Escape" in perl <bill@ts1000.us>
Re: Edit file in place using perl script <jurgenex@hotmail.com>
Re: Edit file in place using perl script <tim@burlyhost.com>
Re: Edit file in place using perl script <smallpond@juno.com>
Re: Help: How to install a *.pm module <cartercc@gmail.com>
Re: Help: How to install a *.pm module <tim@burlyhost.com>
Re: Help: How to install a *.pm module <news@lawshouse.org>
Re: Help: How to install a *.pm module <tim@burlyhost.com>
Re: Help: How to install a *.pm module cyrusgreats@gmail.com
Need help on AoH or array or any other help I can get f cyrusgreats@gmail.com
Re: Need help on AoH or array or any other help I can g <jurgenex@hotmail.com>
Need help on AoH or array or any other think that might cyrusgreats@gmail.com
Re: Need help on AoH or array or any other think that m <glex_no-spam@qwest-spam-no.invalid>
Re: Need help on AoH or array or any other think that m <jurgenex@hotmail.com>
Re: Need help on AoH or array or any other think that m cyrusgreats@gmail.com
Re: Need help on AoH or array or any other think that m <tim@burlyhost.com>
Re: Newlines on Windows <hjp-usenet2@hjp.at>
Re: PDL::Audio not working for me <joost@zeekat.nl>
SOS: Need help on this script if you can ...million tha cyrusgreats@gmail.com
Re: SOS: Need help on this script if you can ...million <jurgenex@hotmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 17 Oct 2008 16:20:32 -0700 (PDT)
From: Bill H <bill@ts1000.us>
Subject: Re: "Escape" in perl
Message-Id: <900e1707-e160-4781-87dd-8233fced8dd4@x41g2000hsb.googlegroups.com>
On Oct 16, 8:18=A0pm, s...@netherlands.com wrote:
> On Thu, 16 Oct 2008 15:21:21 -0700 (PDT), Bill H <b...@ts1000.us> wrote:
> >I am using the following code to unescape html text that is coming
> >from flash:
>
> >sub unescape
> >{
> > =A0 =A0my $text =3D shift;
> > =A0 =A0$text =3D~ s/%(..)/pack("c",hex($1))/ge;
> > =A0 =A0return($text);
> >}
>
> >for example it will take this text:
>
> >%3CFONT%20FACE%3D%22timesnewroman%22%20COLOR%3D%22#000000%22%20SIZE%3D
> >%2220%22%3E%3CP%20ALIGN%3D%22CENTER%22%3EChapter%20Title%3C%2FP%3E%3C
> >%2FFONT%3E
>
> >and it will convert it to this:
>
> ><FONT FACE=3D"timesnewroman" COLOR=3D"#000000" SIZE=3D"20"><P
> >ALIGN=3D"CENTER">Chapter Title</P></FONT>
>
> >What I am trying to figure out is how to go the other way in perl,
> >convert the html to an escaped format. Any hints, clues, pointers
> >would be appreciated
>
> >Bill H
>
> This might be one way:
>
> sub escape
> {
> =A0 =A0 my $text =3D shift;
> =A0 =A0 $text =3D~ s/([<>=3D "#])/'%'.uc sprintf("%x", ord($1))/ge;
> =A0 =A0 return($text);
>
>
>
> }- Hide quoted text -
>
> - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
Thanks! This works great
Bill H
------------------------------
Date: Fri, 17 Oct 2008 09:04:44 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Edit file in place using perl script
Message-Id: <nddhf4hmasff8e8hbtued76s255dv2uetg@4ax.com>
khan <mushtaqk921@gmail.com> wrote:
>I have a requirement where i need to edit the file, based on some
>tokens.
>My requirement is something like this:
>1. If token1 is found delete that line from the file.
next if index ($_, $token1) >= 0
>2. If token2 is found replace some part of that line with replacement
>string.
s/\Q$somepart\E/$replacementstring/ if index ($_, $token2) >= 0
>3. If token3 is found delete that line and next line in the file.
if (index ($_, $token3) >= 0) {
undef = <>; #skip next line
next;
}
>I wrote a script to do this,
You have an error on line 42.
>but since file-pointer is moved after
>reading it is not editing the file at correct positions.
>Please let me know a solution.
perldoc -q "delete a line":
How do I change one line in a file/delete a line in a file/insert a
line in the middle of a file/append to the beginning of a file?
jue
------------------------------
Date: Fri, 17 Oct 2008 10:37:38 -0700
From: Tim Greer <tim@burlyhost.com>
Subject: Re: Edit file in place using perl script
Message-Id: <D34Kk.620$V35.57@newsfe14.iad>
khan wrote:
> Hi,
>
> I have a requirement where i need to edit the file, based on some
> tokens.
> My requirement is something like this:
> 1. If token1 is found delete that line from the file.
> 2. If token2 is found replace some part of that line with replacement
> string.
> 3. If token3 is found delete that line and next line in the file.
>
> I wrote a script to do this, but since file-pointer is moved after
> reading it is not editing the file at correct positions.
> Please let me know a solution.
>
> Thanks,
> -Mushtaq Khan
Please show the code from the script that you said you have already
created to do this, and people can point out the problem with it.
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!
------------------------------
Date: Fri, 17 Oct 2008 14:39:16 -0700 (PDT)
From: smallpond <smallpond@juno.com>
Subject: Re: Edit file in place using perl script
Message-Id: <674dcb59-959a-4421-9ff9-7d7690b5e63e@c60g2000hsf.googlegroups.com>
On Oct 17, 8:49 am, khan <mushtaqk...@gmail.com> wrote:
> Hi,
>
> I have a requirement where i need to edit the file, based on some
> tokens.
> My requirement is something like this:
> 1. If token1 is found delete that line from the file.
> 2. If token2 is found replace some part of that line with replacement
> string.
> 3. If token3 is found delete that line and next line in the file.
>
> I wrote a script to do this, but since file-pointer is moved after
> reading it is not editing the file at correct positions.
> Please let me know a solution.
>
> Thanks,
> -Mushtaq Khan
perldoc perlrun
The -i switch explains how to do this
1) rename the original file to file.bak
2) if successful, open a new file for output
3) if successful, read the original file, and write to the new file
4) loop through all lines
5) if successful, unlink file.bak
Using -i saves writing the file and loop code.
------------------------------
Date: Fri, 17 Oct 2008 09:54:13 -0700 (PDT)
From: cartercc <cartercc@gmail.com>
Subject: Re: Help: How to install a *.pm module
Message-Id: <a5a44973-2a96-4dc3-bb78-b1c0e3130b26@y29g2000hsf.googlegroups.com>
On Oct 17, 9:09=A0am, Amy Lee <openlinuxsou...@gmail.com> wrote:
> Hello,
>
> I download a module for BLAST parsing called "BPlite.pm", however I don't
> know how to install it. I just understand how to install modules packages
> bu cpan.
If your BPlite.pm file is source, which it probably is, just place the
file in the appropriate directory, and use the appropriate 'use'
directive. As far as I know, a source file saved as a package is just
like any user defined file saved as a package. You might have other
problems is your pm file depends on other files, but for now, I'll
consider those kinds of problems outside the scope of your question.
CC
------------------------------
Date: Fri, 17 Oct 2008 10:39:25 -0700
From: Tim Greer <tim@burlyhost.com>
Subject: Re: Help: How to install a *.pm module
Message-Id: <h54Kk.655$V35.367@newsfe14.iad>
Amy Lee wrote:
> Hello,
>
> I download a module for BLAST parsing called "BPlite.pm", however I
> don't know how to install it. I just understand how to install modules
> packages bu cpan.
>
> Thanks in advance.
>
> Amy
The module should have a README and/or INSTALL file. If it doesn't come
with install instructions, I don't know that I'd suggest using it.
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!
------------------------------
Date: Fri, 17 Oct 2008 18:53:40 +0100
From: Henry Law <news@lawshouse.org>
Subject: Re: Help: How to install a *.pm module
Message-Id: <1224266020.8947.0@proxy00.news.clara.net>
Tad J McClellan wrote:
> Amy Lee <openlinuxsource@gmail.com> wrote:
>
>> I download a module for BLAST parsing called "BPlite.pm", however I don't
>> know how to install it.
>
>
> Here is a radical idea: read the file in the distribution named "INSTALL"!
And if the distribution doesn't have a file called that? (It doesn't).
And if the "distribution" isn't a distribution but just a bare Perl
module file? (It is).
Amy, I have downloaded the module and had a look at it for you. As far
as I can see I agree with the suggestion from cartercc: just get the
module into one of the @INC libraries and then "use" it. Mail me
directly if you need help with that.
The module has pod documentation which I presume you found (at a shell
issue perldoc /wherever/it/is/now/BPLite.pm ) but it only tells you how
to use it.
--
Henry Law Manchester, England
------------------------------
Date: Fri, 17 Oct 2008 12:17:51 -0700
From: Tim Greer <tim@burlyhost.com>
Subject: Re: Help: How to install a *.pm module
Message-Id: <Ax5Kk.27853$SH5.18540@newsfe08.iad>
Henry Law wrote:
> Tad J McClellan wrote:
>> Amy Lee <openlinuxsource@gmail.com> wrote:
>>
>>> I download a module for BLAST parsing called "BPlite.pm", however I
>>> don't know how to install it.
>>
>>
>> Here is a radical idea: read the file in the distribution named
>> "INSTALL"!
>
> And if the distribution doesn't have a file called that? (It doesn't).
> And if the "distribution" isn't a distribution but just a bare Perl
> module file? (It is).
>
Isn't this a core module in BioPerl? Not that they couldn't install it
alone, but BioPerl 1.5.2 and all of the previous versions come with it,
as well as many other core modules.
http://search.cpan.org/~sendu/bioperl/
http://search.cpan.org/src/SENDU/bioperl-1.5.2_102/INSTALL
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!
------------------------------
Date: Fri, 17 Oct 2008 14:52:31 -0700 (PDT)
From: cyrusgreats@gmail.com
Subject: Re: Help: How to install a *.pm module
Message-Id: <78f2d2a8-9078-460b-83f8-65899a9dc261@b38g2000prf.googlegroups.com>
On Oct 17, 7:09=A0am, Amy Lee <openlinuxsou...@gmail.com> wrote:
> Hello,
>
> I download a module for BLAST parsing called "BPlite.pm", however I don't
> know how to install it. I just understand how to install modules packages
> bu cpan.
>
> Thanks in advance.
>
> Amy
from shell you can type:
perl -MCPAN -e shell
then type install module
for eaxmple: install
cpan> install Net::Packet
Cheers
------------------------------
Date: Fri, 17 Oct 2008 14:43:06 -0700 (PDT)
From: cyrusgreats@gmail.com
Subject: Need help on AoH or array or any other help I can get for this task
Message-Id: <fc555cd4-dda9-42aa-a499-b29919b47637@o40g2000prn.googlegroups.com>
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 advance
------------------------------
Date: Fri, 17 Oct 2008 16:21:07 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Need help on AoH or array or any other help I can get for this task
Message-Id: <2d7if4dhd5uimmae9tdtpc6plherjprv8c@4ax.com>
cyrusgreats@gmail.com wrote:
>Hello good people out there. I need to write a perl script that will
[...]
>foreach my $line (FILE) {
> my ($customer_name, $product_cat, $item_desc, $cost) = split("|",
>$line);
>
>
>what should I do here
Ask the person who assigned the home work to you, maybe?
jue
------------------------------
Date: Fri, 17 Oct 2008 14:33:26 -0700 (PDT)
From: cyrusgreats@gmail.com
Subject: Need help on AoH or array or any other think that might help!
Message-Id: <10727982-edb0-4707-85b8-dfec05da18e8@g25g2000prf.googlegroups.com>
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
Any help will be appreciated...million thanks in advance
------------------------------
Date: Fri, 17 Oct 2008 16:59:13 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Need help on AoH or array or any other think that might help!
Message-Id: <48f90ab1$0$89876$815e3792@news.qwest.net>
cyrusgreats@gmail.com wrote:
> Hello good people out there. I need to write a perl script that will
> parse the log and generate the following output:
What have you done so far and what questions do you have?
> Any help will be appreciated...million thanks in advance
Put in some sort of effort by at least reading some
documentation, or maybe a book, and posting your code.
perldoc -f split
perldoc -f open
perldoc perldsc
------------------------------
Date: Fri, 17 Oct 2008 16:22:34 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Need help on AoH or array or any other think that might help!
Message-Id: <rm6if4lvhcgn5roj44r8v50q1r3b5ksbup@4ax.com>
cyrusgreats@gmail.com wrote:
>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
perldoc -f split:
($customer, $category, undef, $price) = split ('|');
Then add the totals in hashes:
$byCategory{$customer}{$category} += $price;
$totals{$customer} += $price;
>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.
Walking through the hashes and printing the accumulated data should be
trivial now.
jue
------------------------------
Date: Fri, 17 Oct 2008 17:50:57 -0700 (PDT)
From: cyrusgreats@gmail.com
Subject: Re: Need help on AoH or array or any other think that might help!
Message-Id: <6135a600-a172-41f3-b836-56e0c0e0b14c@w24g2000prd.googlegroups.com>
On Oct 17, 2:59=A0pm, "J. Gleixner" <glex_no-s...@qwest-spam-no.invalid>
wrote:
> cyrusgre...@gmail.com wrote:
> > Hello good people out there. I need to write a perl script that will
> > parse the log and generate the following output:
>
> What have you done so far and what questions do you have?
>
> > Any help will be appreciated...million thanks in advance
>
> Put in some sort of effort by at least reading some
> documentation, or maybe a book, and posting your code.
>
> perldoc -f split
> perldoc -f open
> perldoc perldsc
here portion of the code:
my %inventory;
open (FILE, $file) || die ("Could not open file. $!");
foreach my $el (<FILE)>) {
($name, $category, $item, $price) =3D split ("|", $el);
my %s =3D (
'name'=3D>$name,
'product'=3D>$category,
'item'=3D>$item,
'price'=3D>$$price,
);
push @arr, \%s;
}
foreach $el (@$arr) {
$inventory{$el)->{'name'} =3D {name=3D>$el->{'name'}};
$inventory{$el)->{'product'} =3D {category=3D>$el->{'category'}};
$inventory{$el)->{'item'} =3D {item=3D>$el->{'item'}};
$inventory{$el)->{'price'} =3D {price=3D>$el->{'price'}};
}
Am I in right track?
------------------------------
Date: Fri, 17 Oct 2008 18:07:57 -0700
From: Tim Greer <tim@burlyhost.com>
Subject: Re: Need help on AoH or array or any other think that might help!
Message-Id: <OFaKk.30967$SH5.1037@newsfe08.iad>
cyrusgreats@gmail.com wrote:
> On Oct 17, 2:59Â pm, "J. Gleixner" <glex_no-s...@qwest-spam-no.invalid>
> wrote:
>> cyrusgre...@gmail.com wrote:
>> > Hello good people out there. I need to write a perl script that
>> > will parse the log and generate the following output:
>>
>> What have you done so far and what questions do you have?
>>
>> > Any help will be appreciated...million thanks in advance
>>
>> Put in some sort of effort by at least reading some
>> documentation, or maybe a book, and posting your code.
>>
>> perldoc -f split
>> perldoc -f open
>> perldoc perldsc
>
> here portion of the code:
>
> my %inventory;
> open (FILE, $file) || die ("Could not open file. $!");
> foreach my $el (<FILE)>) {
^^^ You should always copy and paste your actual code you're using. The
above is broken: (<FILE)>)
> ($name, $category, $item, $price) = split ("|", $el);
I don't think that's going to do what you want. Did you print the
output to ensure it's going to work how you want, before you save the
values into a hash. I'd start there, fixing those issues, before you
try and move onto saving the hash keys/values and processing against
it.
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!
------------------------------
Date: Fri, 17 Oct 2008 23:36:42 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Newlines on Windows
Message-Id: <slrngfi1be.6sr.hjp-usenet2@hrunkner.hjp.at>
On 2008-10-14 03:25, David Combs <dkcombs@panix.com> wrote:
> In article <slrngdvijq.o9j.hjp-usenet2@hrunkner.hjp.at>,
> Peter J. Holzer <hjp-usenet2@hjp.at> wrote:
>>On 2008-09-28 09:38, Jürgen Exner <jurgenex@hotmail.com> wrote:
>>> "Peter J. Holzer" <hjp-usenet2@hjp.at> wrote:
>>>>It is worth noting that the translation Jürgen talks about happens
>>>>only during file I/O. Inside of a perl script, "\n" is always a
>>>>single character ("\015" on old MacOS, "\012" on Unix, Windows, and
>>>>(I think) also on MacOS X). When writing to a file with the :crlf
>>>>I/O layer enabled (which is the default on Windows, but you can turn
>>>>it off with binmode or an argument to open), the single "\n" is
>>>>converted to "\015\012". The reverse conversion is done when reading
>>>>a file with the :crlf layer.
>>>
>>> To be crystal clear on that: did you mean "writing to a file" or
>>> "writing to a file handle"?
>>
>>File handle.
>
> I'm a bit puzzled by your question, file or file-handle.
>
> Suppose he'd answered "writing to a file".
>
> How would your answer be different?
I'm not quite sure who you mean by "you" and "he". But anyway:
It is conceivable that perl behaves differently for file handles which
refer to files (i.e., byte streams stored on a random access medium such
as a disk) and file handles which refer to other objects (pipes,
sockets, terminals, ...). In fact, perl does make a similar distinction
for buffering (file handles referring to terminals are by default
line-buffered, file handles referring to sockets are unbuffered, and
everything else is block-buffered). However, for I/O layers there is no
such distinction - what I wrote is true for all kinds of file handles,
not just for file handles referring to files.
hp
------------------------------
Date: Fri, 17 Oct 2008 21:01:37 +0200
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: PDL::Audio not working for me
Message-Id: <878wsnf3la.fsf@zeekat.nl>
kieran <kieranocall@gmail.com> writes:
> Hi all,
> I am relatively new to perl and have just begun using the PDL::Audio
> module. I am having trouble getting basic functionality working, for
> example "describe_audio" should return the number of samples in an
> audio file. I have tried using the following code to find the number
> of sample in a wav file.
>
> use PDL;
> use PDL::Audio;
>
> $pdl = raudio "hello1.wav";
> print "\n\n", describe_audio pdl, "\n";
>
> The output i get for any wav file is as follows: "mono sound with
> samples"
> where there should be either mono or stereo (I always get mono, even
> for stereo files)
> Also there should be a number of samples such as "mono file with
> 1234567 samples", but it is always blank.
> Any suggestions?
I don't use PDL::Audio, if all you want is to check out the meta-data on
an audio file, and/or read the sample data, there are more modules out
there if PDL::Audio doesn't work for you.
I would suggest Audio::SndFile it should work for both data and
meta-data, but it needs libsndfile and I'm biased since I wrote it :-)
--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
------------------------------
Date: Fri, 17 Oct 2008 15:31:14 -0700 (PDT)
From: cyrusgreats@gmail.com
Subject: SOS: Need help on this script if you can ...million thanks in advance
Message-Id: <86c934fb-d2a0-4de7-9bbb-afffb895d1b0@b38g2000prf.googlegroups.com>
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
------------------------------
Date: Fri, 17 Oct 2008 16:07:51 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: SOS: Need help on this script if you can ...million thanks in advance
Message-Id: <jd6if412nb3u9qnuke48gq9sd62f5pjg0j@4ax.com>
cyrusgreats@gmail.com wrote:
[Multiple copies of the same request]
Please see http://www.catb.org/~esr/faqs/smart-questions.html#urgent
jue
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V11 Issue 1930
***************************************