The stupid question is the question not asked | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
That is not going to do quite what you'd hoped. The first time into the loop it will read the first line of the file into the $_ variable, which you never use so that line will be lost. Then, inside the loop you read the file handle in list context as you have an array on the LHS. That will have the effect of reading the remaining lines of the file, one line per element, into the array; the the loop will exit on the next iteration as EOF has been reached. Your array will contain all lines but the first. As you've discovered in your subsequent post you will have to chomp to get rid of line terminators. The correct way to populate your array in a loop would be to use push.
However, there is an easier way as chomp will also operate on arrays
or even
I hope this is helpful. Cheers, JohnGG In reply to Re^3: Substring comparison
by johngg
|
|