in reply to Count the number of lines in a file
It's also something I could see someone doing self-study in perl might choose as a sample problem to solve themselves.
Either way, my answer is going to be the same: Read the documentation.
Specifically, you'll probably want to open a file for reading and/or writing (check the perl docs for the "open" function), use a while loop to read each line in the file one by one (check the docs for the "while" statement), find the length of the line read (can you guess the function name to find the length of a string?), and possibly look up how to print stuff to a file.
It's sort of cheating to do system("wc -lc $infile > $outfile"); in my opinion.
|
---|