Re: Fw: perl help

2003-03-27 Thread Kenzo

- Original Message -
From: "Nikolay Y. Orlyuk" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, March 27, 2003 8:57 AM
Subject: Re: Fw: perl help


> On Thu, Mar 27, 2003 at 08:45:15AM -0600, Kenzo wrote:
> > Bounced
> > try again.
> >
> > - Original Message -
> > From: "Kenzo" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Thursday, March 27, 2003 8:28 AM
> > Subject: Re: perl help
> >
> >
> > > This works great.
> > > now I just realized something else.
> > > What if I wanted to show and count everything after a specific word.
> > >
> > > if I have a sentence like this.
> > > I went to the store with joe/mike and paul
> > >
> > > I want to show how many times "joe/mike and paul" appears.
> > >
> > > The script below will only show joe if I input the word with.
> > > so the desired output would be
> > > joe/mike and paul40
> > >
> > > then if I have a similar sentence like
> > > I went to the store with paul and mike
> > > the output will would be
> > > paul and mike25
> ??
> Where is problem?

there is not problem.
the scripts works like it's suppose to.
but what I would like now is to display and count the rest of the sentence
not just the next word.

> > >
> > > Thanks.
> > >
> > > - Original Message -
> > > From: "Steve Willoughby" <[EMAIL PROTECTED]>
> > > To: "Dan Nelson" <[EMAIL PROTECTED]>
> > > Cc: <[EMAIL PROTECTED]>
> > > Sent: Wednesday, March 26, 2003 4:47 PM
> > > Subject: Re: perl help
> > >
> > >
> > > > > In the last episode (Mar 27), Giorgos Keramidas said:
> > > > > > On 2003-03-26 14:18, Kenzo <[EMAIL PROTECTED]> wrote:
> > > > > > You don't need Perl for that.  Here's a small trick:
> > > > > > grep 'this' file | wc -l
> > > > > > grep 'that' file | wc -l
> > > > > Even better:
> > > > > grep -c 'this' file
> > > > > grep -c 'that' file
> > > >
> > > > Unfortunately, that's not what he was asking for, which is to look
for
> > > > the pattern "big " where all the possible s are unknown
and
> > > > report on all the s that were found.
> > > >
> > > > So something like:
> > > >
> > > > while (<>) {
> > > > while (/big\s+(\w+)/g) {
> > > > $count{$1}++;
> $_=$';
> > > > }
> > > > }
> > > >
> > > > foreach $word (sort(keys(%count))) {
> > > > print "$word: $count{$word}\n";
> > > > }
> > > >
> > > >
> > > > ought to do the trick.  Play with $/, etc if you want to allow big
and
> > > >  to be across a newline from each other.
> I can't understand this messages. Please say what you want and which
problems
> meeted while you solve it.
>
> --
> With best wishes Nikolay
> mail: [EMAIL PROTECTED]
> ICQ#: 136497739
>
> ___
> [EMAIL PROTECTED] mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to
"[EMAIL PROTECTED]"
>
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: Fw: perl help

2003-03-27 Thread Nikolay Y. Orlyuk
On Thu, Mar 27, 2003 at 08:45:15AM -0600, Kenzo wrote:
> Bounced
> try again.
> 
> - Original Message -
> From: "Kenzo" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, March 27, 2003 8:28 AM
> Subject: Re: perl help
> 
> 
> > This works great.
> > now I just realized something else.
> > What if I wanted to show and count everything after a specific word.
> >
> > if I have a sentence like this.
> > I went to the store with joe/mike and paul
> >
> > I want to show how many times "joe/mike and paul" appears.
> >
> > The script below will only show joe if I input the word with.
> > so the desired output would be
> > joe/mike and paul40
> >
> > then if I have a similar sentence like
> > I went to the store with paul and mike
> > the output will would be
> > paul and mike25
??
Where is problem?
> >
> > Thanks.
> >
> > - Original Message -----
> > From: "Steve Willoughby" <[EMAIL PROTECTED]>
> > To: "Dan Nelson" <[EMAIL PROTECTED]>
> > Cc: <[EMAIL PROTECTED]>
> > Sent: Wednesday, March 26, 2003 4:47 PM
> > Subject: Re: perl help
> >
> >
> > > > In the last episode (Mar 27), Giorgos Keramidas said:
> > > > > On 2003-03-26 14:18, Kenzo <[EMAIL PROTECTED]> wrote:
> > > > > You don't need Perl for that.  Here's a small trick:
> > > > > grep 'this' file | wc -l
> > > > > grep 'that' file | wc -l
> > > > Even better:
> > > > grep -c 'this' file
> > > > grep -c 'that' file
> > >
> > > Unfortunately, that's not what he was asking for, which is to look for
> > > the pattern "big " where all the possible s are unknown and
> > > report on all the s that were found.
> > >
> > > So something like:
> > >
> > > while (<>) {
> > > while (/big\s+(\w+)/g) {
> > > $count{$1}++;
$_=$';
> > > }
> > > }
> > >
> > > foreach $word (sort(keys(%count))) {
> > > print "$word: $count{$word}\n";
> > > }
> > >
> > >
> > > ought to do the trick.  Play with $/, etc if you want to allow big and
> > >  to be across a newline from each other.
I can't understand this messages. Please say what you want and which problems
meeted while you solve it.

-- 
With best wishes Nikolay
mail: [EMAIL PROTECTED]
ICQ#: 136497739

___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Fw: perl help

2003-03-27 Thread Kenzo
Bounced
try again.

- Original Message -
From: "Kenzo" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, March 27, 2003 8:28 AM
Subject: Re: perl help


> This works great.
> now I just realized something else.
> What if I wanted to show and count everything after a specific word.
>
> if I have a sentence like this.
> I went to the store with joe/mike and paul
>
> I want to show how many times "joe/mike and paul" appears.
>
> The script below will only show joe if I input the word with.
> so the desired output would be
> joe/mike and paul40
>
> then if I have a similar sentence like
> I went to the store with paul and mike
> the output will would be
> paul and mike25
>
> Thanks.
>
> - Original Message -
> From: "Steve Willoughby" <[EMAIL PROTECTED]>
> To: "Dan Nelson" <[EMAIL PROTECTED]>
> Cc: <[EMAIL PROTECTED]>
> Sent: Wednesday, March 26, 2003 4:47 PM
> Subject: Re: perl help
>
>
> > > In the last episode (Mar 27), Giorgos Keramidas said:
> > > > On 2003-03-26 14:18, Kenzo <[EMAIL PROTECTED]> wrote:
> > > > You don't need Perl for that.  Here's a small trick:
> > > > grep 'this' file | wc -l
> > > > grep 'that' file | wc -l
> > > Even better:
> > > grep -c 'this' file
> > > grep -c 'that' file
> >
> > Unfortunately, that's not what he was asking for, which is to look for
> > the pattern "big " where all the possible s are unknown and
> > report on all the s that were found.
> >
> > So something like:
> >
> > while (<>) {
> > while (/big\s+(\w+)/g) {
> > $count{$1}++;
> > }
> > }
> >
> > foreach $word (sort(keys(%count))) {
> > print "$word: $count{$word}\n";
> > }
> >
> >
> > ought to do the trick.  Play with $/, etc if you want to allow big and
> >  to be across a newline from each other.
> > --
> > Steve Willoughby  | "The purpose of IT is to seamlessly and
trans-
> > Intel DPG Eng. Computing  | parently provide the other nine-tenths of
the
> > Application Development   | iceburg for people who need to work with
> chunks
> > <[EMAIL PROTECTED]>  | of floating ice."   --Strata R.
Chalup
> >
> >
> > ___
> > [EMAIL PROTECTED] mailing list
> > http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> > To unsubscribe, send any mail to
> "[EMAIL PROTECTED]"
> >
>
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: perl help

2003-03-27 Thread David Landgren
Kenzo wrote:

[resend. I sent this yesterday but it doesn't appear to have turned up 
on the list.]

I don't know how to write anything in perl and will eventually learn it.
but I was wondering if anyone would help write a quick perl script for 
me.
You really ought to try a different forum. Perl Monks 
(http://www.perlmonks.org/) springs to mind.

Basically I want the script to look thru a file for certain words and 
cound
how many times it finds the word that comes after.
I have a log file that keeps track of E-mail attachments being send and
received, and I want to be able to do a count of certain attachments.
for example. say I see alot of "big this", "big that" and "big nothing"
I want to be able to see how many times the word that comes after big
appears in the log file.
so the output would be like this.
this5
that 10
nothing 20
Well that's pretty easy...

#! /usr/bin/perl -w

use strict;

my $target = shift or die "No target word given on command line";
my $prev;
my %follow;
while( <> ) {
   chomp;
   # break the line into elements
   my @word = split;
   # deal with the leftover of the previous line
   ++$follow{$word[0]} if $prev and $prev eq $target;
   # walk down the line
   $word[$_] eq $target and ++$follow{$word[$_+1]} for 0 .. @word - 2;
   # carry over the last word to the next line
   $prev = $word[-1];
}
# print out the results
print "$_\t$follow{$_}\n" for sort keys %follow;
I hope this is not too confusing.
I might say the same of my script :)

thanks.
You're welcome.
David
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: perl help

2003-03-26 Thread Steve Willoughby
> In the last episode (Mar 27), Giorgos Keramidas said:
> > On 2003-03-26 14:18, Kenzo <[EMAIL PROTECTED]> wrote:
> > You don't need Perl for that.  Here's a small trick:
> > grep 'this' file | wc -l
> > grep 'that' file | wc -l
> Even better:
>   grep -c 'this' file
>   grep -c 'that' file

Unfortunately, that's not what he was asking for, which is to look for 
the pattern "big " where all the possible s are unknown and
report on all the s that were found.

So something like:

while (<>) {
while (/big\s+(\w+)/g) {
$count{$1}++;
}
}

foreach $word (sort(keys(%count))) {
print "$word: $count{$word}\n";
}


ought to do the trick.  Play with $/, etc if you want to allow big and
 to be across a newline from each other.
-- 
Steve Willoughby  | "The purpose of IT is to seamlessly and trans-
Intel DPG Eng. Computing  | parently provide the other nine-tenths of the
Application Development   | iceburg for people who need to work with chunks 
<[EMAIL PROTECTED]>  | of floating ice."   --Strata R. Chalup


___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: perl help

2003-03-26 Thread Dan Nelson
In the last episode (Mar 27), Giorgos Keramidas said:
> On 2003-03-26 14:18, Kenzo <[EMAIL PROTECTED]> wrote:
> > Basically I want the script to look thru a file for certain words
> > and cound how many times it finds the word that comes after. I have
> > a log file that keeps track of E-mail attachments being send and
> > received, and I want to be able to do a count of certain
> > attachments. for example. say I see alot of "big this", "big that"
> > and "big nothing" I want to be able to see how many times the word
> > that comes after big appears in the log file.
> >
> > so the output would be like this.
> > this5
> > that 10
> > nothing 20
> 
> You don't need Perl for that.  Here's a small trick:
> 
>   grep 'this' file | wc -l
>   grep 'that' file | wc -l
>   ...

Even better:

grep -c 'this' file
grep -c 'that' file

-- 
Dan Nelson
[EMAIL PROTECTED]
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: perl help

2003-03-26 Thread Giorgos Keramidas
On 2003-03-26 14:18, Kenzo <[EMAIL PROTECTED]> wrote:
> I don't know how to write anything in perl and will eventually learn it.
> but I was wondering if anyone would help write a quick perl script for me.
>
> Basically I want the script to look thru a file for certain words and cound
> how many times it finds the word that comes after.
> I have a log file that keeps track of E-mail attachments being send and
> received, and I want to be able to do a count of certain attachments.
> for example. say I see alot of "big this", "big that" and "big nothing"
> I want to be able to see how many times the word that comes after big
> appears in the log file.
> so the output would be like this.
> this5
> that 10
> nothing 20

You don't need Perl for that.  Here's a small trick:

grep 'this' file | wc -l
grep 'that' file | wc -l
...

- Giorgos
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


perl help

2003-03-26 Thread Kenzo
I don't know how to write anything in perl and will eventually learn it.
but I was wondering if anyone would help write a quick perl script for me.

Basically I want the script to look thru a file for certain words and cound
how many times it finds the word that comes after.
I have a log file that keeps track of E-mail attachments being send and
received, and I want to be able to do a count of certain attachments.
for example. say I see alot of "big this", "big that" and "big nothing"
I want to be able to see how many times the word that comes after big
appears in the log file.
so the output would be like this.
this5
that 10
nothing 20

I hope this is not too confusing.

thanks.
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"