I' ve a problem about counting name in a string. Name has format {#name} such as {#john} or {#mr_peter}... A name include lowercase character, digits or underline "_" character is valid.

And, enter a paragraph, how many name in this. Exam: Input: {#john} and {#conankudo} play PES with {#mr_invincible}. { {#john} win {###} { Output: 4 because have 4 name is: {#john}, {#conankudo}, {#mr_invincible} and {#john}.

Not only is your test of eof unnecessary, it probably does not do what you think (Refer perldoc -f eof).

You must correct my typo as Shawn pointed out.

This program will accept input from STDIN (usually the keyboard) until it reads an end-of-file. The way you type an end-of-file depends on your operating system. (For windows, use CTRL-Z followed by ENTER.)

Although it has nothing to do with you current problem, you should always use the pragmas "use strict" and "use warnings". This will force you to declare all your variables (almost always with "my"). Good Luck, Bill