It depends on what you mean by word I would assume you could do something
like
%seen = ();
while( ) {
$seen{lc $_}++ for( split /\s+/ );
}
- Original Message -
From: "ANIDIL RAJENDRAN" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, September 17, 2002 11:42 AM
Subject: Count
Are you only looking for 'california' (case-sensitive?) ?
if so:
open (FILE,"C:\\proj\\order\.txt") or die "cannot open file: $!";
%seen = ();
while () {
$count += s/california//g; ## substitute returns number of subs
(m// doesn't)
}
print "california: $count\n";
> -Original Messa
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