in reply to checking the end of line
If you don't mind me asking, what exactly do you hope to gain out of PerlMonks here? A lot of people have been providing you with answers in the form of raw code, but it doesn't look like you've learned a whole lot through your petitioning.
In addition, we tend to frown on requesting code to solve homework problems. While we've no real evidence that you're doing this as part of your homework, the fact that you have a shadow here posting very similar questions makes me wonder.
It might help us if you took a step back and tried to think of what you're wanting to learn here and ask for help learning these concepts instead of asking for help solving very specific (and seemingly contrived) text processing problems over and over again.