[22662] in Perl-Users-Digest
Perl-Users Digest, Issue: 4883 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 24 00:10:42 2003
Date: Wed, 23 Apr 2003 21:10:10 -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 Wed, 23 Apr 2003 Volume: 10 Number: 4883
Today's topics:
Re: Tough question for the guru's; Grep Once, Awk Twice (Agrapha)
Re: Tough question for the guru's; Grep Once, Awk Twice <uri@stemsystems.com>
Re: Tough question for the guru's; Grep Once, Awk Twice (Agrapha)
Re: Tough question for the guru's; Grep Once, Awk Twice (Agrapha)
Re: Tough question for the guru's; Grep Once, Awk Twice <uri@stemsystems.com>
Re: Tough question for the guru's; Grep Once, Awk Twice <uri@stemsystems.com>
Re: Tough question for the guru's; Grep Once, Awk Twice (Agrapha)
Re: Tough question for the guru's; Grep Once, Awk Twice (Agrapha)
Re: Tough question for the guru's; Grep Once, Awk Twice <uri@stemsystems.com>
Re: Tough question for the guru's; Grep Once, Awk Twice (Sam Holden)
Re: Tough question for the guru's; Grep Once, Awk Twice <uri@stemsystems.com>
Re: Tough question for the guru's; Grep Once, Awk Twice <ethan@draupnir.gso.saic.com>
Re: Tough question for the guru's; Grep Once, Awk Twice (Randal L. Schwartz)
Re: Tough question for the guru's; Grep Once, Awk Twice (Randal L. Schwartz)
Re: Tough question for the guru's; Grep Once, Awk Twice (Agrapha)
Re: Tough question for the guru's; Grep Once, Awk Twice (Agrapha)
Re: Tough question for the guru's; Grep Once, Awk Twice (Tad McClellan)
Re: Tough question for the guru's; Grep Once, Awk Twice (Tad McClellan)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 23 Apr 2003 15:14:52 -0700
From: brian@box201.com (Agrapha)
Subject: Re: Tough question for the guru's; Grep Once, Awk Twice (or more)
Message-Id: <11aabb15.0304231414.2937f4a6@posting.google.com>
> I think you want <http://jobs.perl.org>. You can find a contractor
> for hire there. Be sure to mention how much you're willing to pay.
>
> Either that, or <http://learn.perl.org>, which has a list of good
> resources for you to learn Perl on your own.
>
> Your choice. Pay, or learn.
>
> When you actually have a Perl question, perhaps you can post your
> in-progress Perl script here, including the question you next face.
>
> print "Just another Perl hacker,"
Remember when you asked someone for help? Was it so long ago? Is your
own personal brain synapse so critical to life on earth that you
cannot assist a journey? Do you truly think it so incredibly wrong to
give assistance? Quick before you answer run to a mirror and watch
yourself say it. "I will not help but will only inflame the animosity
of those requesting my help"
print " may I never become a primadonna! ";
------------------------------
Date: Wed, 23 Apr 2003 22:22:02 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Tough question for the guru's; Grep Once, Awk Twice (or more)
Message-Id: <x7sms8q2gl.fsf@mail.sysarch.com>
>>>>> "A" == Agrapha <brian@box201.com> writes:
A> Remember when you asked someone for help? Was it so long ago? Is your
A> own personal brain synapse so critical to life on earth that you
A> cannot assist a journey? Do you truly think it so incredibly wrong to
A> give assistance? Quick before you answer run to a mirror and watch
A> yourself say it. "I will not help but will only inflame the animosity
A> of those requesting my help"
A> print " may I never become a primadonna! ";
too bad, you are one already.
do you realize who you just slammed? look him up on google and see if he
ever has helped the perl community.
you on the other hand likes to bite the hand that feeds you.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: 23 Apr 2003 15:32:23 -0700
From: brian@box201.com (Agrapha)
Subject: Re: Tough question for the guru's; Grep Once, Awk Twice (or more)
Message-Id: <11aabb15.0304231432.6c5e9d72@posting.google.com>
>
> whew, 244 word and not 1 bit of code. you beat me!! and please post this
> in a php group and let them do your work for you.
>
Too busy reminding primadonnas they too need assistance sometimes.
> so whip up the perl code in a hurry and show that.
>
I'm working on it but learing enough perl to whip up something in less
than 24 hours is a daunting task. But I'm working on it. Please stand
by. I can't wait to hear your sarcastic comments on my first attemp at
perl...
>
> i am not pleased with how much time you are wasting here. think about
> all the man-hours you have wasted by begging for a perl translation.
>
It's my weekend what can I say. I work on things I can use while away
from work.
> FYI: this group is not a free perl translation service. if you had
> posted even a minimal and highly broken perl script you would have
> gotten help.
Doubtful. Only one person even attemped directions. So far you have
contributed zero to this discussion. How would you load 100,000
records with 10 fields? an array? The fields are separated by
whitespace. Is there a module I should look at? Can I use some kind of
DBI= function.
------------------------------
Date: 23 Apr 2003 15:43:12 -0700
From: brian@box201.com (Agrapha)
Subject: Re: Tough question for the guru's; Grep Once, Awk Twice (or more)
Message-Id: <11aabb15.0304231443.7f4d37b9@posting.google.com>
> >> this is a perl discussion group and not a rewrite my shell script in
> >> perl for me group.
There is little discussion of perl so far. Most of it is "the proper
way to flame and attack" group.
> That is your concern, not our concern.
>
>
> > if I can only get complaints about posting then I shall look
> > elsewhere.
>
>
> Thank you.
Oh no, I a perma-member now. Soley because of your post.
btw thank you for driving me to it. I would have probably blown it off
as a place for fantasy armchair programmers but not after your post.
------------------------------
Date: Wed, 23 Apr 2003 22:47:59 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Tough question for the guru's; Grep Once, Awk Twice (or more)
Message-Id: <x7ptncq19c.fsf@mail.sysarch.com>
>>>>> "A" == Agrapha <brian@box201.com> writes:
>>
>> whew, 244 word and not 1 bit of code. you beat me!! and please post this
>> in a php group and let them do your work for you.
>>
A> Too busy reminding primadonnas they too need assistance sometimes.
sure and i try first before i ask for more help.
A> I'm working on it but learing enough perl to whip up something in less
A> than 24 hours is a daunting task. But I'm working on it. Please stand
A> by. I can't wait to hear your sarcastic comments on my first attemp at
A> perl...
you still haven't shown any perl code. no help or sarcasm can be given
with that.
>> i am not pleased with how much time you are wasting here. think about
>> all the man-hours you have wasted by begging for a perl translation.
>>
A> It's my weekend what can I say. I work on things I can use while away
A> from work.
you are very clueless. you wasted the time of all the people who read
your post. your time doesn't matter. this is called being selfish. ask
you mommy what that means.
>> FYI: this group is not a free perl translation service. if you had
>> posted even a minimal and highly broken perl script you would have
>> gotten help.
A> Doubtful. Only one person even attemped directions. So far you have
A> contributed zero to this discussion. How would you load 100,000
A> records with 10 fields? an array? The fields are separated by
A> whitespace. Is there a module I should look at? Can I use some kind of
A> DBI= function.
and you still haven't posted any perl code so your doubtfullness is in
doubt.
you can use many solutions including looping over the file, slurping it,
using DBI.
local $/ ;
my @rows = map [split ' '], <> ;
anything else you need, your holiness?
i will send my bill if you send me your address.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Wed, 23 Apr 2003 22:51:48 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Tough question for the guru's; Grep Once, Awk Twice (or more)
Message-Id: <x7n0igq12z.fsf@mail.sysarch.com>
>>>>> "A" == Agrapha <brian@box201.com> writes:
>> >> this is a perl discussion group and not a rewrite my shell script in
>> >> perl for me group.
A> There is little discussion of perl so far. Most of it is "the proper
A> way to flame and attack" group.
there is plenty of perl discussion in all the other threads. the only
difference in this one is that you asked for free coding services and
didn't post any code. i wonder why you got such a fun welcome. many
newbies and others don't have this problem. so i vote that you are the
reason you were treated this way. i bet most of the others here would
vote that way too.
A> Oh no, I a perma-member now. Soley because of your post.
A> btw thank you for driving me to it. I would have probably blown it off
A> as a place for fantasy armchair programmers but not after your post.
fantasy? heheh.
you are severely lacking in clue about usenet if that is what you
think. but your lack of usenet skills is obvious. try this attitude
elsewhere and enjoy.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: 23 Apr 2003 18:15:28 -0700
From: brian@box201.com (Agrapha)
Subject: Re: Tough question for the guru's; Grep Once, Awk Twice (or more)
Message-Id: <11aabb15.0304231715.6c62587d@posting.google.com>
> >> >> this is a perl discussion group and not a rewrite my shell script in
> >> >> perl for me group.
no this is the "how mayeth I hinder thy search" group.
> there is plenty of perl discussion in all the other threads. the only
> difference in this one is that you asked for free coding services and
> didn't post any code. i wonder why you got such a fun welcome. many
> newbies and others don't have this problem. so i vote that you are the
> reason you were treated this way. i bet most of the others here would
> vote that way too.
is there? nope not buying it. Way too much rations of attitude trashed
on me the moment I stepped foot in here.
> fantasy? heheh.
fantasy.
> you are severely lacking in clue about usenet if that is what you think.
no I have a very cheery attitude when attacked. I enjoy the banter. It
keeps me interested, especially when I ask for help. Just because I
won't let it go doesn't mean you need to continue. If anything, I am
persistant.
------------------------------
Date: 23 Apr 2003 18:33:44 -0700
From: brian@box201.com (Agrapha)
Subject: Re: Tough question for the guru's; Grep Once, Awk Twice (or more)
Message-Id: <11aabb15.0304231733.62676537@posting.google.com>
> PS A few lines of data would have made your shell script miles easier to
> understand :-)
Rick here is what I have so far. It's rough but touches on some of the
commands you suggested. The crux of the problem is becoming appearent.
#!/usr/bin/env perl -w #fire up the perl engine
use strict; # let the compiler check my work for
typos
open(PROXYD, "proxyD.0423") or die "Can't open input.txt: $!"; #
open file
my @RAWDATA = <PROXYD>; #push handle to @array
my $i=1;
foreach (@RAWDATA) { #counts the number records in the open
file
$i++;
}
print $i, " records in this file\n";
print @RAWDATA[860..$#RAWDATA]; #manually pull and print last 5 log
lines
close PROXYD; #save some memory here
my $FAIL = 987; #this section is my attempt to get an
average
my $TOTAL = 9786;
my $ACSR = (100 - (($FAIL / $TOTAL) * 100));
print int($ACSR), "\%\n"; # seemed to work!
#####end of script
the output is as follows:
865 records in this file
proxyD.20030420:00:43:53 Stop BRI 9065551212 9065559385 28,758
46667,28800 244,736 nas1.IsleofMan1 1-1-2:8 1-5-18 net/bri
dlp.purple42.S0018.0001.prod
proxyD.20030420:00:43:54 Stop BRI 9065551225 9065559385 32,0
50667,24000 33,185 nas2.IsleofMan1 1-1-2:21 1-4-72 NoUserName
proxyD.20030420:00:43:55 Stop BRI 9065551216 9065559385 26,2073
46667,46667 64.42 nas5.IsleofMan1 1-1-1:10 1-2-63
net/bri.dlp.ppena.101201.0000.prod
proxyD.20030420:00:43:55 Stop BRI 9065551242 9065559385 58,0
50667,24000 101,4, nas2.IsleofMan1 1-1-2:21 1-4-72 NoUserName
89%
these lines all happen to be stop records. There are start records
too. my original script greped the ",0 " to pull the lines where
someone didn't get on. this grabs the error after 2nd phone number
like 32,0. I used a grep -c to count them. what is a good way to use a
count option in perl's grep?
------------------------------
Date: Thu, 24 Apr 2003 02:07:06 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Tough question for the guru's; Grep Once, Awk Twice (or more)
Message-Id: <x74r4ops1h.fsf@mail.sysarch.com>
>>>>> "A" == Agrapha <brian@box201.com> writes:
>> you are severely lacking in clue about usenet if that is what you think.
A> no I have a very cheery attitude when attacked. I enjoy the banter. It
A> keeps me interested, especially when I ask for help. Just because I
A> won't let it go doesn't mean you need to continue. If anything, I am
A> persistant.
oh, please. we outlasted a massive moronic troll. you are nothing in
comparison. just a little wiseguy who needs help and doesn't know how to
ask politely and with respect for the culture of this group. that shows
so much usenet experience and even your cheery attitude. where was the
cheer when you replied to me? in fact i haven't seen any yet.
and i posted code to solve one of your queries and you didn't even thank
me. for shame!
maybe you would be polite enough to try it and even humble enough to ask
how it works. you might even learn some perl, heaven forbid! but then
again, this is a perl newsgroup where teaching and learning perl have
been going on for years without you. i think it will survive with you
here or not. so don't think you bother me nor anyone else. just learn
some perl and try to fit in for a change.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: 24 Apr 2003 02:07:29 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: Tough question for the guru's; Grep Once, Awk Twice (or more)
Message-Id: <slrnbaehmv.eqm.sholden@flexal.cs.usyd.edu.au>
On 23 Apr 2003 18:33:44 -0700, Agrapha <brian@box201.com> wrote:
>> PS A few lines of data would have made your shell script miles easier to
>> understand :-)
>
> Rick here is what I have so far. It's rough but touches on some of the
> commands you suggested. The crux of the problem is becoming appearent.
>
> #!/usr/bin/env perl -w #fire up the perl engine
> use strict; # let the compiler check my work for
> typos
> open(PROXYD, "proxyD.0423") or die "Can't open input.txt: $!"; #open file
^^^^^^^^^^^ ^^^^^^^^^
One of those is wrong, inconsistancies like that are the cause of nightmares
next week when it keeps saying 'input.txt not found' and you can see it
clearly does exist...
> my @RAWDATA = <PROXYD>; #push handle to @array
> my $i=1;
> foreach (@RAWDATA) { #counts the number records in the open
> file
> $i++;
> }
That's truly daft...
my $i = @RAWDATA;
Accomplishes the same thing in less than linear time.
> print $i, " records in this file\n";
print scalar @RAWDATA, " records in this file\n";
if that's all you use $i for.
> print @RAWDATA[860..$#RAWDATA]; #manually pull and print last 5 log
If you know 860 is 5 from the end, then why did you bother counting
the lines above? If it isn't always going to be 860 why not $#RAWDATA-5?
Even better use negative indexing:
print @RAWDATA[-5..-1];
If you only want to keep the last five lines for output purposes, you
don't have read the whole thing in at once:
my @RAWDATA;
while (<PROXYD>) {
push @RAWDATA, $_;
shift @RAWDATA if @RAWDATA>5;
}
That will probably be slower, but will use less memory and won't result in
swapping and big slow downs if you end up with really large files (unless
you have really long lines :).
> lines
> close PROXYD; #save some memory here
>
> my $FAIL = 987; #this section is my attempt to get an
> average
> my $TOTAL = 9786;
> my $ACSR = (100 - (($FAIL / $TOTAL) * 100));
> print int($ACSR), "\%\n"; # seemed to work!
> #####end of script
Your code is wrapping lines, this is bad... it makes things not work without
fixing it. It would be nice if you could fix that before posting.
>
> the output is as follows:
>
> 865 records in this file
> proxyD.20030420:00:43:53 Stop BRI 9065551212 9065559385 28,758
> 46667,28800 244,736 nas1.IsleofMan1 1-1-2:8 1-5-18 net/bri
> dlp.purple42.S0018.0001.prod
> proxyD.20030420:00:43:54 Stop BRI 9065551225 9065559385 32,0
> 50667,24000 33,185 nas2.IsleofMan1 1-1-2:21 1-4-72 NoUserName
> proxyD.20030420:00:43:55 Stop BRI 9065551216 9065559385 26,2073
> 46667,46667 64.42 nas5.IsleofMan1 1-1-1:10 1-2-63
> net/bri.dlp.ppena.101201.0000.prod
> proxyD.20030420:00:43:55 Stop BRI 9065551242 9065559385 58,0
> 50667,24000 101,4, nas2.IsleofMan1 1-1-2:21 1-4-72 NoUserName
> 89%
I see only 4 lines of output...
>
> these lines all happen to be stop records. There are start records
> too. my original script greped the ",0 " to pull the lines where
> someone didn't get on. this grabs the error after 2nd phone number
> like 32,0. I used a grep -c to count them. what is a good way to use a
> count option in perl's grep?
$counter++;
or
$counter=@matches;
--
Sam Holden
------------------------------
Date: Thu, 24 Apr 2003 02:12:35 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Tough question for the guru's; Grep Once, Awk Twice (or more)
Message-Id: <x71xzsprsc.fsf@mail.sysarch.com>
>>>>> "A" == Agrapha <brian@box201.com> writes:
>> PS A few lines of data would have made your shell script miles easier to
>> understand :-)
wow! some real code!!
A> Rick here is what I have so far. It's rough but touches on some of the
A> commands you suggested. The crux of the problem is becoming appearent.
A> #!/usr/bin/env perl -w #fire up the perl engine
A> use strict; # let the compiler check my work for
A> typos
use a better emailer as this is wrapping and making the code unpastable.
A> open(PROXYD, "proxyD.0423") or die "Can't open input.txt: $!"; #
A> my @RAWDATA = <PROXYD>; #push handle to @array
A> my $i=1;
A> foreach (@RAWDATA) { #counts the number records in the open
A> file
A> $i++;
A> }
gack! this is perl, not c. you even use $#RAWDATA below so why in the
world do you count the records by hand?
A> close PROXYD; #save some memory here
doesn't save anything worth worrying about. you just slurped in a whole
file which is much greater than one filehandle
A> my $FAIL = 987; #this section is my attempt to get an
A> average
A> my $TOTAL = 9786;
don't use upper case variable names.
A> my $ACSR = (100 - (($FAIL / $TOTAL) * 100));
put the int there if you need it
my $ACSR = int(100 - (($FAIL / $TOTAL) * 100));
A> print int($ACSR), "\%\n"; # seemed to work!
no need to escape % in a ctring. and without the int it can be all in
one string
A> like 32,0. I used a grep -c to count them. what is a good way to use a
A> count option in perl's grep?
you don't. you use a hash and count unique lines that way.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: 23 Apr 2003 19:18:56 -0700
From: Ethan Brown <ethan@draupnir.gso.saic.com>
Subject: Re: Tough question for the guru's; Grep Once, Awk Twice (or more)
Message-Id: <vrof2wbptb.fsf@draupnir.gso.saic.com>
>>>>> "Agrapha" == Agrapha <brian@box201.com> writes:
>> PS A few lines of data would have made your shell script miles easier to
>> understand :-)
Agrapha> Rick here is what I have so far. It's rough but touches on some of the
Agrapha> commands you suggested. The crux of the problem is becoming appearent.
Hi Brian. Here are a few things I see that might clean things up.
Agrapha> #!/usr/bin/env perl -w #fire up the perl engine
Agrapha> use strict; # let the compiler check my work for
Agrapha> typos
Good for you. Always enable warnings and strictures.
Agrapha> open(PROXYD, "proxyD.0423") or die "Can't open input.txt: $!"; #
Agrapha> open file
Agrapha> my @RAWDATA = <PROXYD>; #push handle to @array
Agrapha> my $i=1;
Agrapha> foreach (@RAWDATA) { #counts the number records in the open
Agrapha> file
Agrapha> $i++;
Agrapha> }
One of the cool (or confusing :-) things about Perl is you get
different results for different "contexts". For example, there is an
array context and a scalar context. The scalar context of an array is
the number of elements in the array. Following this? :-) You can
just say:
$i = @RAWDATA; # $i now has the number of elements in @RAWDATA
and skip the foreach loop.
Agrapha> print $i, " records in this file\n";
Agrapha> print @RAWDATA[860..$#RAWDATA]; #manually pull and print last 5 log
Agrapha> lines
It may be that the number of lines in your file will someday change.
To print the last 5 lines, you can do:
print @RAWDATA[$#RAWDATA - 4 .. $#RAWDATA]
but that prints things all together. Let's put spaces between the
elements when we print them out:
print join(' ', @RAWDATA[$#RAWDATA - 4 .. $#RAWDATA])
Agrapha> like 32,0. I used a grep -c to count them. what is a good way to use a
Agrapha> count option in perl's grep?
Perl's grep is different from the Unix grep. If want to count how
many records have a certain attribute you can use grep, but it's
probably better to use a loop and a regular expression. In the case of
the ",0" indicator:
my $errors = 0;
foreach (@RAWDATA) {$errors++ if /,0/}
Keep in mind, in Perl there is always many ways to do something.
There are most likely other "more elegent" ways of doing what I've
suggested.
Good luck,
--Ethan Brown
--Keyboards: "The Fabulous Pelicans" (www.pelicans.com)
--In a band? Use http://www.WheresTheGig.com for free.
------------------------------
Date: Thu, 24 Apr 2003 02:33:18 GMT
From: merlyn@stonehenge.com (Randal L. Schwartz)
To: brian@box201.com (Agrapha)
Subject: Re: Tough question for the guru's; Grep Once, Awk Twice (or more)
Message-Id: <ccab2517189d6734e2b6f4c2d63936e0@TeraNews>
>>>>> "Agrapha" == Agrapha <brian@box201.com> writes:
Agrapha> Remember when you asked someone for help? Was it so long ago?
Agrapha> Is your own personal brain synapse so critical to life on
Agrapha> earth that you cannot assist a journey? Do you truly think it
Agrapha> so incredibly wrong to give assistance? Quick before you
Agrapha> answer run to a mirror and watch yourself say it. "I will not
Agrapha> help but will only inflame the animosity of those requesting
Agrapha> my help"
This is a community potluck. Not a restaurant. Not even a soup
kitchen. What did you bring? What? Not even cooking utensils? How
disrespectful.
I mean you no harm, personally. Just helping you to understand how it
works here.
print "Just another Perl hacker,"
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Thu, 24 Apr 2003 02:33:19 GMT
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Tough question for the guru's; Grep Once, Awk Twice (or more)
Message-Id: <02e70fd05d537050ea4515d45fa1f07d@TeraNews>
>>>>> "Abigail" == Abigail <abigail@abigail.nl> writes:
Abigail> I'll write your program for you, for $150/hour, 4 hour minimum.
Hey, *I'll* write your program for half that! $75/hr (8 hour minimum)
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: 23 Apr 2003 20:04:16 -0700
From: brian@box201.com (Agrapha)
Subject: Re: Tough question for the guru's; Grep Once, Awk Twice (or more)
Message-Id: <11aabb15.0304231838.4689051c@posting.google.com>
> Not if you can avoid it.
>
> open F, "file" or die $!;
> while (<F>) {
> # each line now in $_ including terminating newline
> ...
> }
nice, I think I understand.
my @SELECT = grep (",0 ") 0..#$F;
will load all the failed calls into @SELECT
foreach (@SELECT) {
$i++;
}
can count them.
How would I count how many different types there are if I don't know
what kinds will be returned? what would I use in place of the "uniq
-c" command?
> This is also true if you slurp the file like this:
>
> my @lines = <F>;
ok it's a tcsh shell thing. When my shell script loaded all that the
grep found into a variable it did so by changing it all to 1 very long
string which could not be processed by awk. But in perl, if I use your
idea and skim the data while incrementing counters it might work. I
wonder if I used a %hash, Can I change the values on the fly? whoa,
That might work. Here is 1 record:
proxyD.20030420:00:43:55 Stop BRI 9065551242 9065559385 58,0
50667,24000 101,4 nas2.IsleofMan1 1-1-2:21 1-4-72 NoUserName
ok so field #8 is my error codes. They could be anything, it's a
refernce number from 0 thru 200 comma 0 thru 9000. If there is a way
to load an array or hash with the error code and then how many times
it occured? that would be it!
How can I load an @array with and error code and keep incrementing the
number of times it occurs in my file if I don't know what it will be?
In the line above the "101,4" is the error. Am I asking for 2
dimension array? How would I make a 3 dimension one? like this:
24 101,4 9065551242
16 33,185 9065551242
10 101,4 9065541268
etc...
first column = number of occurances this day
of second column error codes from
third column phone numbers.
all I need to do is read the file (100,000 lines) and keep
incrementing the counter of the first column.
> You might get away without them, depends on your needs. You most often
> will use references when you construct nested data-structures, a
> two-dimensional array for instance.
>
> References however are documented quite extensively throughout the
> perldocs. Try
>
> perldoc perlreftut # tutorial
> perldoc perlref # the complete reference to, alas, references
> perldoc perldsc # data structure cookbook
> perldoc perllol # working with multi-dimensional arrays
>
good, my FreeBSD machine @ home will help with those. Thanks. I think
I'm after the multi-dimentional array.
I guess that is one of the main reasons I didn't learn perl in the
first place. I get a huge ration everytime I request assistance. Even
within my own company. My sarcasm gets the better of me sometimes but
there is always a few quality people who help me greatly. Thank you
for slowing down enough to help this average technician.
------------------------------
Date: 23 Apr 2003 20:54:56 -0700
From: brian@box201.com (Agrapha)
Subject: Re: Tough question for the guru's; Grep Once, Awk Twice (or more)
Message-Id: <11aabb15.0304231954.15acb862@posting.google.com>
>
> do you realize who you just slammed? look him up on google and see if he
> ever has helped the perl community.
Honestly I am hear to learn and not to banter. If you have the ability
to help then please do so. How do I scan thru a flat text file grab a
value and count the number of times it occurs. The value looks a lot
like "101,4"
>
> you on the other hand likes to bite the hand that feeds you.
>
and so far you have fed me insults. If you do not have a desire to
help others then please feel free to continue this argument by
yourself. I formally apologise for requesting help from you, Uri. I'll
not make that mistake again.
Are you an important person? I don't know. I suspect if we look with
open eyes we can boil the importance off and find a person underneath.
------------------------------
Date: Wed, 23 Apr 2003 22:43:17 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Tough question for the guru's; Grep Once, Awk Twice (or more)
Message-Id: <slrnbaenal.1u9.tadmc@magna.augustmail.com>
Agrapha <brian@box201.com> wrote:
> Way too much rations of attitude trashed
> on me the moment I stepped foot in here.
Maybe there was something in your entrance that encouraged
such responses.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 23 Apr 2003 22:46:33 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Tough question for the guru's; Grep Once, Awk Twice (or more)
Message-Id: <slrnbaengp.1u9.tadmc@magna.augustmail.com>
Agrapha <brian@box201.com> wrote:
[attribution left out by OP, it is Randal Schwartz being quoted]
>> When you actually have a Perl question, perhaps you can post your
>> in-progress Perl script here, including the question you next face.
> Do you truly think it so incredibly wrong to
> give assistance?
Excuse me, but your ignorance is showing.
Randal has helped countless people here over many years.
> print " may I never become a primadonna! ";
Too late for you.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
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.
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 V10 Issue 4883
***************************************