24-09-2013, 02:21 PM
COUNT THE NUMBER OF WORDS,CHARACTERS AND LINES
NUMBER OF WORDS.pdf (Size: 25.86 KB / Downloads: 16)
AIM :
To count the number of lines, words and characters in a given file usin perl.
ALGORITHM :
Step 1 : Start the program,
Step 2 : Open the file and store the data in an array a
Step 3 : Print the number of lines using scalar function
Step 4 : Close the file
Step 5 : Open the file, initialize a with 0
Step 6 : Get the character using getc function untill it reach end of file, increment the count
Step 7 : Print the count value
Step 8 : Close the file
Step 9 : Open the file, initialize a with 0
Step 10 : Get the character using getc function and initialize to k untill it reach end of file, check k value is not equal then
increment the count
Step 11 : Print the count value
Step 12 : Close the file
Step 13 : Stop the program
RESULT :
Thus the above script count the number of lines, words and characters in a given file using perl has been done and
verified .