Running under w2k as build 623 5.6.0 and did what you wanted.

Wags ;)

-----Original Message-----
From: Bruce Ambraal [mailto:[EMAIL PROTECTED]]
Sent: Thursday, April 04, 2002 16:59
To: [EMAIL PROTECTED]
Subject: Spit the input in whitespace



One last request please run the code below and see whether it does 
the following

With the code below (see attached) I tried to do following:
Read from STDIN, 
splits the input in whitespace, 
and prints the frequency of terms, with each term printed next to its
frequency on STDOUT. 

According to me it does not print any info to STDOUT.
This is my problem
-------------------------------------------------------------------------------------------------------------------
#!/usr/bin/perl -w
open (OUTPUT, ">file.out")||die;
my %freq;
while (my $line  = <STDIN>) {
    foreach my $w ( split( /\s+/, $line ) ){
        if( exists $freq{$w} ){ 
            $freq{$w}++; 
        }else{
            $freq{$w} = 1;
        }
    }
}
foreach my $k ( keys( %freq ) ){
   print OUTPUT  "$k $freq{$k}\n";
print STDOUT  "$k $freq{$k}\n";

} 

close (OUTPUT);





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to