Log in



Tags » ‘find’

How do you find out the amount of lines that a user has entered in a Perl program?

November 14th, 2010 by

Question by MOUSIE: How do you find out the amount of lines that a user has entered in a Perl program?

Best answer:

Answer by martinthurn
my $iCount = 0;
while (my $sLine = <>)
{
# do something with the user’s input. And then:
$iCount++;
} # while
# When you’re all done:
print “User entered $iCount lines\n”;

Add your own answer in the comments!

How do I find these patterns in Perl?

November 4th, 2010 by

Question by lamar211us: How do I find these patterns in Perl?
1. I need to search for words in a file that begin with “p” and “P” and words that end with “p” and “P” and print them out.

2. I need to search for lines in a file containing a period, question mark, or comma at the end of the line. When these lines are found, I need to print onlt the part of the line that occurs after the word “it”.

Best answer:

Answer by Interview Question And Answer
(~= ^p||^P )&&(~=$p||$P)

Give your answer to this question below!


Powered by Yahoo! Answers