trewq has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks,

When you read lines from a file you use, for example, <FILE>.
Until what character does the perl read the line?
I mean, what is the "end of the line" mark? Does it add this mark to the beginning of the second line read?

Thanks

Replies are listed 'Best First'.
Re: Reading lines from a file
by ELISHEVA (Prior) on Aug 06, 2009 at 05:50 UTC

    Welcome to PerlMonks!

    That depends on what value you assign to the variable $/. By default, it is set to the new line character (\n) but it can be set to any character or even a string with many characters. See perlvar.

    Every time you read a line, Perl reads upto and including the end of line mark set in $/. To remove the end of line mark from a line you just read in, you use chomp. You may also find this link in the perl documentation helpful: How-can-I-read-in-an-entire-file-all-at-once?.

    In the future you may want to consider asking simple questions about the meaning of terms in the chatter box (look for it on the sidebar on the right). In the chatterbox we can quickly go back and forth to clear up any misunderstandings. Another comment: I strongly encourage you to follow those documentation links. Perl documentation can be hard to read when you are first beginning, but the more you do it, the easier it gets. The more you expose yourself to programming jargon, the faster you will progress.

    Best, beth