2002 11:42 AM
Subject: Counting the same word
Hi,
I want to count the number of times a particular word occured in a file.
Though the following script is working, is it possible to shorten it?
--
open (FILE,"C:\\proj\\order\.txt") or die "cannot open file: $!";
%see
california: $count\n";
> -Original Message-
> From: ANIDIL RAJENDRAN [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, September 17, 2002 11:43 AM
> To: [EMAIL PROTECTED]
> Subject: Counting the same word
>
>
> Hi,
> I want to count the number of times a partic
unts the word once per line..
> if the word was in the line twice it would only count it once.
>
> > -Original Message-
> > From: Mat Harris [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, September 17, 2002 12:06 PM
> > To: ANIDIL RAJENDRAN
> > Cc: [EM
]
> Subject: Re: Counting the same word
>
>
> i think this will work, but don't complain if it doesn't 'cos
> im tired. ok?
>
> #!/usr/bin/perl
>
> $count = 0;
> while ()
> {
> if (m/california/)
> {
>
i think this will work, but don't complain if it doesn't 'cos im tired. ok?
#!/usr/bin/perl
$count = 0;
while ()
{
if (m/california/)
{
$count++;
}
}
print "california: $count\n";
On Tue, Sep 17, 2002 at 08:42:57 -0700, AN
Hi,
I want to count the number of times a particular word occured in a file. Though the
following script is working, is it possible to shorten it?
--
open (FILE,"C:\\proj\\order\.txt") or die "cannot open file: $!";
%seen = ();
while () {
while ( /(\w['\w-]*)/g) {
$seen{lc $1}++;
}
}