In the program below I don't know when to stop the loop.
(CTRL + d ) will just terminate the program, leaving the data via STDIN unattended,
this is my problem.
Lets define what I want to do:
I want to print the frequency of every word at the beginning. and every word at the
end of a line.
This could mean two things:
1) one line of text to be read in and on pressing <enter> code below
will analyse the input.
2) a paragraph containing a number of lines get adressed.
I think my code adress 2) but problem with this is that I don't know when my coding
should jump out of the loop?
Any ideas
> #!/usr/bin/perl
> while (<STDIN>) {
> if (/(\b[^\W_\d][\w-]+\b)/g) {
> $gotit{$1}++;
> }
> if (/(\b[^\W_\d][\w-]+\b\Z)/g) {
> $found{$1}++;
> }
>
> }
> while (($wrd,$cnt)= each %gotit){
> print "$cnt $wrd\n";
> }#end of while
>
> foreach my $yes (keys (%found)){
> print "$found{$yes} $yes\n";
> }#end foreach
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]